Merge branch '3.0' into feat/sangshuduo/TD-14141-update-taostools-for3.0
This commit is contained in:
commit
8ecd50b653
|
@ -8,17 +8,17 @@ description: "创建、删除数据库,查看、修改数据库参数"
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
CREATE DATABASE [IF NOT EXISTS] db_name [database_options]
|
CREATE DATABASE [IF NOT EXISTS] db_name [database_options]
|
||||||
|
|
||||||
database_options:
|
database_options:
|
||||||
database_option ...
|
database_option ...
|
||||||
|
|
||||||
database_option: {
|
database_option: {
|
||||||
BUFFER value
|
BUFFER value
|
||||||
| CACHEMODEL {'none' | 'last_row' | 'last_value' | 'both'}
|
| CACHEMODEL {'none' | 'last_row' | 'last_value' | 'both'}
|
||||||
| CACHESIZE value
|
| CACHESIZE value
|
||||||
| COMP {0 | 1 | 2}
|
| COMP {0 | 1 | 2}
|
||||||
| DURATION value
|
| DURATION value
|
||||||
| FSYNC value
|
| WAL_FSYNC_PERIOD value
|
||||||
| MAXROWS value
|
| MAXROWS value
|
||||||
| MINROWS value
|
| MINROWS value
|
||||||
| KEEP value
|
| KEEP value
|
||||||
|
@ -28,7 +28,7 @@ database_option: {
|
||||||
| REPLICA value
|
| REPLICA value
|
||||||
| RETENTIONS ingestion_duration:keep_duration ...
|
| RETENTIONS ingestion_duration:keep_duration ...
|
||||||
| STRICT {'off' | 'on'}
|
| STRICT {'off' | 'on'}
|
||||||
| WAL {1 | 2}
|
| WAL_LEVEL {1 | 2}
|
||||||
| VGROUPS value
|
| VGROUPS value
|
||||||
| SINGLE_STABLE {0 | 1}
|
| SINGLE_STABLE {0 | 1}
|
||||||
| WAL_RETENTION_PERIOD value
|
| WAL_RETENTION_PERIOD value
|
||||||
|
@ -46,7 +46,7 @@ database_option: {
|
||||||
- last_row:表示缓存子表最近一行数据。这将显著改善 LAST_ROW 函数的性能表现。
|
- last_row:表示缓存子表最近一行数据。这将显著改善 LAST_ROW 函数的性能表现。
|
||||||
- last_value:表示缓存子表每一列的最近的非 NULL 值。这将显著改善无特殊影响(WHERE、ORDER BY、GROUP BY、INTERVAL)下的 LAST 函数的性能表现。
|
- last_value:表示缓存子表每一列的最近的非 NULL 值。这将显著改善无特殊影响(WHERE、ORDER BY、GROUP BY、INTERVAL)下的 LAST 函数的性能表现。
|
||||||
- both:表示同时打开缓存最近行和列功能。
|
- both:表示同时打开缓存最近行和列功能。
|
||||||
- CACHESIZE:表示缓存子表最近数据的内存大小。默认为 1 ,范围是[1, 65536],单位是 MB。
|
- CACHESIZE:表示每个 vnode 中用于缓存子表最近数据的内存大小。默认为 1 ,范围是[1, 65536],单位是 MB。
|
||||||
- COMP:表示数据库文件压缩标志位,缺省值为 2,取值范围为 [0, 2]。
|
- COMP:表示数据库文件压缩标志位,缺省值为 2,取值范围为 [0, 2]。
|
||||||
- 0:表示不压缩。
|
- 0:表示不压缩。
|
||||||
- 1:表示一阶段压缩。
|
- 1:表示一阶段压缩。
|
||||||
|
|
|
@ -40,7 +40,6 @@ ALTER ALL DNODES dnode_option
|
||||||
|
|
||||||
dnode_option: {
|
dnode_option: {
|
||||||
'resetLog'
|
'resetLog'
|
||||||
| 'resetQueryCache'
|
|
||||||
| 'balance' value
|
| 'balance' value
|
||||||
| 'monitor' value
|
| 'monitor' value
|
||||||
| 'debugFlag' value
|
| 'debugFlag' value
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
sidebar_label: taosX
|
||||||
|
title: 使用 taosX 在集群间复制数据
|
||||||
|
---
|
|
@ -1 +1 @@
|
||||||
label: 参考指南
|
label: 参考手册
|
|
@ -1,5 +1,4 @@
|
||||||
---
|
---
|
||||||
sidebar_label: 参考手册
|
|
||||||
title: 参考手册
|
title: 参考手册
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -5,33 +5,29 @@ title: 容量规划
|
||||||
|
|
||||||
使用 TDengine 来搭建一个物联网大数据平台,计算资源、存储资源需要根据业务场景进行规划。下面分别讨论系统运行所需要的内存、CPU 以及硬盘空间。
|
使用 TDengine 来搭建一个物联网大数据平台,计算资源、存储资源需要根据业务场景进行规划。下面分别讨论系统运行所需要的内存、CPU 以及硬盘空间。
|
||||||
|
|
||||||
## 内存需求
|
## 服务端内存需求
|
||||||
|
|
||||||
每个 Database 可以创建固定数目的 vgroup,默认与 CPU 核数相同,可通过 maxVgroupsPerDb 配置;vgroup 中的每个副本会是一个 vnode;每个 vnode 会占用固定大小的内存(大小与数据库的配置参数 blocks 和 cache 有关);每个 Table 会占用与标签总长度有关的内存;此外,系统会有一些固定的内存开销。因此,每个 DB 需要的系统内存可通过如下公式计算:
|
每个 Database 可以创建固定数目的 vgroup,默认 2 个 vgroup,在创建数据库时可以通过`vgroups <num>`参数来指定,其副本数由参数`replica <num>`指定。vgroup 中的每个副本会是一个 vnode;所以每个数据库占用的内存由以下几个参数决定:
|
||||||
|
|
||||||
|
- vgroups
|
||||||
|
- replica
|
||||||
|
- buffer
|
||||||
|
- pages
|
||||||
|
- pagesize
|
||||||
|
- cachesize
|
||||||
|
|
||||||
|
关于这些参数的详细说明请参考 [数据库管理](../taos-sql/database)。
|
||||||
|
|
||||||
|
一个数据库所需要的内存大小等于
|
||||||
|
|
||||||
```
|
```
|
||||||
Database Memory Size = maxVgroupsPerDb * replica * (blocks * cache + 10MB) + numOfTables * (tagSizePerTable + 0.5KB)
|
vgroups * replica * (buffer + pages * pagesize + cachesize)
|
||||||
```
|
```
|
||||||
|
|
||||||
示例:假设 maxVgroupPerDB 是缺省值 64,cache 是缺省大小 16M, blocks 是缺省值 6,并且一个 DB 中有 10 万张表,单副本,标签总长度是 256 字节,则这个 DB 总的内存需求为:64 \* 1 \* (16 \* 6 + 10) + 100000 \* (0.25 + 0.5) / 1000 = 6792M。
|
但要注意的是这些内存并不需要由单一服务器提供,而是由整个集群中所有数据节点共同负担,相当于由这些数据节点所在的服务器共同负担。如果集群中有不止一个数据库,则所需内存要累加,并由集群中所有服务器共同负担。更复杂的场景是如果集群中的数据节点并非在最初就一次性全部建立,而是随着使用中系统负载的增加逐步增加服务器并增加数据节点,则新创建的数据库会导致新旧数据节点上的负载并不均衡,此时简单的理论计算并不能直接使用,要结合各数据节点的负载情况。
|
||||||
|
|
||||||
在实际的系统运维中,我们通常会更关心 TDengine 服务进程(taosd)会占用的内存量。
|
|
||||||
|
|
||||||
```
|
## 客户端内存需求
|
||||||
taosd 内存总量 = vnode 内存 + mnode 内存 + 查询内存
|
|
||||||
```
|
|
||||||
|
|
||||||
其中:
|
|
||||||
|
|
||||||
1. “vnode 内存”指的是集群中所有的 Database 存储分摊到当前 taosd 节点上所占用的内存资源。可以按上文“Database Memory Size”计算公式估算每个 DB 的内存占用量进行加总,再按集群中总共的 TDengine 节点数做平均(如果设置为多副本,则还需要乘以对应的副本倍数)。
|
|
||||||
2. “mnode 内存”指的是集群中管理节点所占用的资源。如果一个 taosd 节点上分布有 mnode 管理节点,则内存消耗还需要增加“0.2KB \* 集群中数据表总数”。
|
|
||||||
3. “查询内存”指的是服务端处理查询请求时所需要占用的内存。单条查询语句至少会占用“0.2KB \* 查询涉及的数据表总数”的内存量。
|
|
||||||
|
|
||||||
注意:以上内存估算方法,主要讲解了系统的“必须内存需求”,而不是“内存总数上限”。在实际运行的生产环境中,由于操作系统缓存、资源管理调度等方面的原因,内存规划应当在估算结果的基础上保留一定冗余,以维持系统状态和系统性能的稳定性。并且,生产环境通常会配置系统资源的监控工具,以便及时发现硬件资源的紧缺情况。
|
|
||||||
|
|
||||||
最后,如果内存充裕,可以考虑加大 Blocks 的配置,这样更多数据将保存在内存里,提高写入和查询速度。
|
|
||||||
|
|
||||||
### 客户端内存需求
|
|
||||||
|
|
||||||
客户端应用采用 taosc 客户端驱动连接服务端,会有内存需求的开销。
|
客户端应用采用 taosc 客户端驱动连接服务端,会有内存需求的开销。
|
||||||
|
|
||||||
|
@ -77,5 +73,3 @@ Raw DataSize = numOfTables * rowSizePerTable * rowsPerTable
|
||||||
根据上面的内存、CPU、存储的预估,就可以知道整个系统需要多少核、多少内存、多少存储空间。如果数据副本数不为 1,总需求量需要再乘以副本数。
|
根据上面的内存、CPU、存储的预估,就可以知道整个系统需要多少核、多少内存、多少存储空间。如果数据副本数不为 1,总需求量需要再乘以副本数。
|
||||||
|
|
||||||
因为 TDengine 具有很好的水平扩展能力,根据总量,再根据单个物理机或虚拟机的资源,就可以轻松决定需要购置多少台物理机或虚拟机了。
|
因为 TDengine 具有很好的水平扩展能力,根据总量,再根据单个物理机或虚拟机的资源,就可以轻松决定需要购置多少台物理机或虚拟机了。
|
||||||
|
|
||||||
**立即计算 CPU、内存、存储,请参见:[资源估算方法](https://www.taosdata.com/config/config.html)。**
|
|
||||||
|
|
|
@ -10,19 +10,21 @@ TDengine 接收到应用的请求数据包时,先将请求的原始数据包
|
||||||
|
|
||||||
涉及的系统配置参数有两个:
|
涉及的系统配置参数有两个:
|
||||||
|
|
||||||
- walLevel:WAL 级别,0:不写 WAL; 1:写 WAL, 但不执行 fsync; 2:写 WAL, 而且执行 fsync。
|
- wal_level:WAL 级别,1:写WAL,但不执行fsync。2:写WAL,而且执行fsync。默认值为 1。
|
||||||
- fsync:当 walLevel 设置为 2 时,执行 fsync 的周期。设置为 0,表示每次写入,立即执行 fsync。
|
- wal_fsync_period:当 wal_evel 设置为 2 时,执行 fsync 的周期。设置为 0,表示每次写入,立即执行 fsync。
|
||||||
|
|
||||||
如果要 100%的保证数据不丢失,需要将 walLevel 设置为 2,fsync 设置为 0。这时写入速度将会下降。但如果应用侧启动的写数据的线程数达到一定的数量(超过 50),那么写入数据的性能也会很不错,只会比 fsync 设置为 3000 毫秒下降 30%左右。
|
如果要 100%的保证数据不丢失,需要将 wal_level 设置为 2,fsync 设置为 0。这时写入速度将会下降。但如果应用侧启动的写数据的线程数达到一定的数量(超过 50),那么写入数据的性能也会很不错,只会比 fsync 设置为 3000 毫秒下降 30%左右。
|
||||||
|
|
||||||
## 灾备
|
## 灾备
|
||||||
|
|
||||||
TDengine 的集群通过多个副本的机制,来提供系统的高可用性,实现灾备能力。
|
TDengine 的集群通过多个副本的机制,来提供系统的高可用性,同时具备一定的灾备能力。
|
||||||
|
|
||||||
TDengine 集群是由 mnode 负责管理的,为保证 mnode 的高可靠,可以配置多个 mnode 副本,副本数由系统配置参数 numOfMnodes 决定,为了支持高可靠,需要设置大于 1。为保证元数据的强一致性,mnode 副本之间通过同步方式进行数据复制,保证了元数据的强一致性。
|
TDengine 集群是由 mnode 负责管理的,为保证 mnode 的高可靠,可以配置 三个 mnode 副本。为保证元数据的强一致性,mnode 副本之间通过同步方式进行数据复制,保证了元数据的强一致性。
|
||||||
|
|
||||||
TDengine 集群中的时序数据的副本数是与数据库关联的,一个集群里可以有多个数据库,每个数据库可以配置不同的副本数。创建数据库时,通过参数 replica 指定副本数。为了支持高可靠,需要设置副本数大于 1。
|
TDengine 集群中的时序数据的副本数是与数据库关联的,一个集群里可以有多个数据库,每个数据库可以配置不同的副本数。创建数据库时,通过参数 replica 指定副本数。为了支持高可靠,需要设置副本数为 3。
|
||||||
|
|
||||||
TDengine 集群的节点数必须大于等于副本数,否则创建表时将报错。
|
TDengine 集群的节点数必须大于等于副本数,否则创建表时将报错。
|
||||||
|
|
||||||
当 TDengine 集群中的节点部署在不同的物理机上,并设置多个副本数时,就实现了系统的高可靠性,无需再使用其他软件或工具。TDengine 企业版还可以将副本部署在不同机房,从而实现异地容灾。
|
当 TDengine 集群中的节点部署在不同的物理机上,并设置多个副本数时,就实现了系统的高可靠性,无需再使用其他软件或工具。TDengine 企业版还可以将副本部署在不同机房,从而实现异地容灾。
|
||||||
|
|
||||||
|
另外一种灾备方式是通过 `taosX` 将一个 TDengine 集群的数据同步复制到物理上位于不同数据中心的另一个 TDengine 集群。其详细使用方法请参考 [taosX 参考手册](../reference/taosX)
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
---
|
|
||||||
title: 用户管理
|
|
||||||
---
|
|
||||||
|
|
||||||
系统管理员可以在 CLI 界面里添加、删除用户,也可以修改密码。CLI 里 SQL 语法如下:
|
|
||||||
|
|
||||||
```sql
|
|
||||||
CREATE USER <user_name> PASS <'password'>;
|
|
||||||
```
|
|
||||||
|
|
||||||
创建用户,并指定用户名和密码,密码需要用单引号引起来,单引号为英文半角
|
|
||||||
|
|
||||||
```sql
|
|
||||||
DROP USER <user_name>;
|
|
||||||
```
|
|
||||||
|
|
||||||
删除用户,限 root 用户使用
|
|
||||||
|
|
||||||
```sql
|
|
||||||
ALTER USER <user_name> PASS <'password'>;
|
|
||||||
```
|
|
||||||
|
|
||||||
修改用户密码,为避免被转换为小写,密码需要用单引号引用,单引号为英文半角
|
|
||||||
|
|
||||||
```sql
|
|
||||||
ALTER USER <user_name> PRIVILEGE <write|read>;
|
|
||||||
```
|
|
||||||
|
|
||||||
修改用户权限为:write 或 read,不需要添加单引号
|
|
||||||
|
|
||||||
说明:系统内共有 super/write/read 三种权限级别,但目前不允许通过 alter 指令把 super 权限赋予用户。
|
|
||||||
|
|
||||||
```sql
|
|
||||||
SHOW USERS;
|
|
||||||
```
|
|
||||||
|
|
||||||
显示所有用户
|
|
||||||
|
|
||||||
:::note
|
|
||||||
SQL 语法中,< >表示需要用户输入的部分,但请不要输入< >本身。
|
|
||||||
|
|
||||||
:::
|
|
|
@ -1,53 +0,0 @@
|
||||||
---
|
|
||||||
title: 系统连接、任务查询管理
|
|
||||||
---
|
|
||||||
|
|
||||||
系统管理员可以从 CLI 查询系统的连接、正在进行的查询、流式计算,并且可以关闭连接、停止正在进行的查询和流式计算。
|
|
||||||
|
|
||||||
## 显示数据库的连接
|
|
||||||
|
|
||||||
```sql
|
|
||||||
SHOW CONNECTIONS;
|
|
||||||
```
|
|
||||||
|
|
||||||
其结果中的一列显示 ip:port, 为连接的 IP 地址和端口号。
|
|
||||||
|
|
||||||
## 强制关闭数据库连接
|
|
||||||
|
|
||||||
```sql
|
|
||||||
KILL CONNECTION <connection-id>;
|
|
||||||
```
|
|
||||||
|
|
||||||
其中的 connection-id 是 SHOW CONNECTIONS 中显示的第一列的数字。
|
|
||||||
|
|
||||||
## 显示数据查询
|
|
||||||
|
|
||||||
```sql
|
|
||||||
SHOW QUERIES;
|
|
||||||
```
|
|
||||||
|
|
||||||
其中第一列显示的以冒号隔开的两个数字为 query-id,为发起该 query 应用连接的 connection-id 和查询次数。
|
|
||||||
|
|
||||||
## 强制关闭数据查询
|
|
||||||
|
|
||||||
```sql
|
|
||||||
KILL QUERY <query-id>;
|
|
||||||
```
|
|
||||||
|
|
||||||
其中 query-id 是 SHOW QUERIES 中显示的 connection-id:query-no 字串,如“105:2”,拷贝粘贴即可。
|
|
||||||
|
|
||||||
## 显示连续查询
|
|
||||||
|
|
||||||
```sql
|
|
||||||
SHOW STREAMS;
|
|
||||||
```
|
|
||||||
|
|
||||||
其中第一列显示的以冒号隔开的两个数字为 stream-id, 为启动该 stream 应用连接的 connection-id 和发起 stream 的次数。
|
|
||||||
|
|
||||||
## 强制关闭连续查询
|
|
||||||
|
|
||||||
```sql
|
|
||||||
KILL STREAM <stream-id>;
|
|
||||||
```
|
|
||||||
|
|
||||||
其中的 stream-id 是 SHOW STREAMS 中显示的 connection-id:stream-no 字串,如 103:2,拷贝粘贴即可。
|
|
|
@ -3044,12 +3044,41 @@ typedef struct SDeleteRes {
|
||||||
int64_t skey;
|
int64_t skey;
|
||||||
int64_t ekey;
|
int64_t ekey;
|
||||||
int64_t affectedRows;
|
int64_t affectedRows;
|
||||||
char tableFName[TSDB_TABLE_FNAME_LEN];
|
char tableFName[TSDB_TABLE_NAME_LEN];
|
||||||
|
char tsColName[TSDB_COL_NAME_LEN];
|
||||||
} SDeleteRes;
|
} SDeleteRes;
|
||||||
|
|
||||||
int32_t tEncodeDeleteRes(SEncoder* pCoder, const SDeleteRes* pRes);
|
int32_t tEncodeDeleteRes(SEncoder* pCoder, const SDeleteRes* pRes);
|
||||||
int32_t tDecodeDeleteRes(SDecoder* pCoder, SDeleteRes* pRes);
|
int32_t tDecodeDeleteRes(SDecoder* pCoder, SDeleteRes* pRes);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t msgType;
|
||||||
|
int32_t msgLen;
|
||||||
|
void* msg;
|
||||||
|
} SBatchMsg;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SMsgHead header;
|
||||||
|
int32_t msgNum;
|
||||||
|
SBatchMsg msg[];
|
||||||
|
} SBatchReq;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int32_t reqType;
|
||||||
|
int32_t msgLen;
|
||||||
|
int32_t rspCode;
|
||||||
|
void* msg;
|
||||||
|
} SBatchRsp;
|
||||||
|
|
||||||
|
static FORCE_INLINE void tFreeSBatchRsp(void *p) {
|
||||||
|
if (NULL == p) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SBatchRsp* pRsp = (SBatchRsp*)p;
|
||||||
|
taosMemoryFree(pRsp->msg);
|
||||||
|
}
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -136,6 +136,7 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_INDEX, "drop-index", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_DROP_INDEX, "drop-index", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_GET_INDEX, "get-index", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_GET_INDEX, "get-index", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_GET_TABLE_INDEX, "get-table-index", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_GET_TABLE_INDEX, "get-table-index", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_MND_BATCH_META, "batch-meta", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_TABLE_CFG, "table-cfg", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_TABLE_CFG, "table-cfg", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_TOPIC, "create-topic", SMCreateTopicReq, SMCreateTopicRsp)
|
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_TOPIC, "create-topic", SMCreateTopicReq, SMCreateTopicRsp)
|
||||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_TOPIC, "alter-topic", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_TOPIC, "alter-topic", NULL, NULL)
|
||||||
|
@ -180,6 +181,7 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_TABLE_META, "vnode-table-meta", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_TABLE_META, "vnode-table-meta", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_TABLES_META, "vnode-tables-meta", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_TABLES_META, "vnode-tables-meta", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_TABLE_CFG, "vnode-table-cfg", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_TABLE_CFG, "vnode-table-cfg", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_VND_BATCH_META, "vnode-batch-meta", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_STB, "vnode-create-stb", SVCreateStbReq, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_STB, "vnode-create-stb", SVCreateStbReq, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_STB, "vnode-alter-stb", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_STB, "vnode-alter-stb", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_STB, "vnode-drop-stb", SVDropStbReq, NULL)
|
TD_DEF_MSG_TYPE(TDMT_VND_DROP_STB, "vnode-drop-stb", SVDropStbReq, NULL)
|
||||||
|
|
|
@ -38,7 +38,8 @@ typedef struct SDeleterRes {
|
||||||
int64_t skey;
|
int64_t skey;
|
||||||
int64_t ekey;
|
int64_t ekey;
|
||||||
int64_t affectedRows;
|
int64_t affectedRows;
|
||||||
char tableFName[TSDB_TABLE_FNAME_LEN];
|
char tableName[TSDB_TABLE_NAME_LEN];
|
||||||
|
char tsColName[TSDB_COL_NAME_LEN];
|
||||||
} SDeleterRes;
|
} SDeleterRes;
|
||||||
|
|
||||||
typedef struct SDeleterParam {
|
typedef struct SDeleterParam {
|
||||||
|
|
|
@ -64,17 +64,7 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers);
|
||||||
* @param SReadHandle
|
* @param SReadHandle
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols,
|
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols, SSchemaWrapper** pSchema);
|
||||||
SSchemaWrapper** pSchema);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the input data block for the stream scan.
|
|
||||||
* @param tinfo
|
|
||||||
* @param input
|
|
||||||
* @param type
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
int32_t qSetStreamInput(qTaskInfo_t tinfo, const void* input, int32_t type, bool assignUid);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set multiple input data blocks for the stream scan.
|
* Set multiple input data blocks for the stream scan.
|
||||||
|
@ -84,7 +74,7 @@ int32_t qSetStreamInput(qTaskInfo_t tinfo, const void* input, int32_t type, bool
|
||||||
* @param type
|
* @param type
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type, bool assignUid);
|
int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the table id list, add or remove.
|
* Update the table id list, add or remove.
|
||||||
|
|
|
@ -151,7 +151,8 @@ typedef struct SVnodeModifyLogicNode {
|
||||||
uint64_t tableId;
|
uint64_t tableId;
|
||||||
uint64_t stableId;
|
uint64_t stableId;
|
||||||
int8_t tableType; // table type
|
int8_t tableType; // table type
|
||||||
char tableFName[TSDB_TABLE_FNAME_LEN];
|
char tableName[TSDB_TABLE_NAME_LEN];
|
||||||
|
char tsColName[TSDB_COL_NAME_LEN];
|
||||||
STimeWindow deleteTimeRange;
|
STimeWindow deleteTimeRange;
|
||||||
SVgroupsInfo* pVgroupList;
|
SVgroupsInfo* pVgroupList;
|
||||||
SNodeList* pInsertCols;
|
SNodeList* pInsertCols;
|
||||||
|
@ -494,7 +495,7 @@ typedef struct SQueryInserterNode {
|
||||||
uint64_t tableId;
|
uint64_t tableId;
|
||||||
uint64_t stableId;
|
uint64_t stableId;
|
||||||
int8_t tableType; // table type
|
int8_t tableType; // table type
|
||||||
char tableFName[TSDB_TABLE_FNAME_LEN];
|
char tableName[TSDB_TABLE_NAME_LEN];
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
SEpSet epSet;
|
SEpSet epSet;
|
||||||
} SQueryInserterNode;
|
} SQueryInserterNode;
|
||||||
|
@ -503,7 +504,7 @@ typedef struct SDataDeleterNode {
|
||||||
SDataSinkNode sink;
|
SDataSinkNode sink;
|
||||||
uint64_t tableId;
|
uint64_t tableId;
|
||||||
int8_t tableType; // table type
|
int8_t tableType; // table type
|
||||||
char tableFName[TSDB_TABLE_FNAME_LEN];
|
char tableFName[TSDB_TABLE_NAME_LEN];
|
||||||
char tsColName[TSDB_COL_NAME_LEN];
|
char tsColName[TSDB_COL_NAME_LEN];
|
||||||
STimeWindow deleteTimeRange;
|
STimeWindow deleteTimeRange;
|
||||||
SNode* pAffectedRows;
|
SNode* pAffectedRows;
|
||||||
|
|
|
@ -270,7 +270,7 @@ typedef struct SStreamTask {
|
||||||
int64_t startVer;
|
int64_t startVer;
|
||||||
int64_t checkpointVer;
|
int64_t checkpointVer;
|
||||||
int64_t processedVer;
|
int64_t processedVer;
|
||||||
int32_t numOfVgroups;
|
// int32_t numOfVgroups;
|
||||||
|
|
||||||
// children info
|
// children info
|
||||||
SArray* childEpInfo; // SArray<SStreamChildEpInfo*>
|
SArray* childEpInfo; // SArray<SStreamChildEpInfo*>
|
||||||
|
|
|
@ -2823,35 +2823,35 @@ end:
|
||||||
|
|
||||||
// delete from db.tabl where .. -> delete from tabl where ..
|
// delete from db.tabl where .. -> delete from tabl where ..
|
||||||
// delete from db .tabl where .. -> delete from tabl where ..
|
// delete from db .tabl where .. -> delete from tabl where ..
|
||||||
static void getTbName(char *sql){
|
//static void getTbName(char *sql){
|
||||||
char *ch = sql;
|
// char *ch = sql;
|
||||||
|
//
|
||||||
bool inBackQuote = false;
|
// bool inBackQuote = false;
|
||||||
int8_t dotIndex = 0;
|
// int8_t dotIndex = 0;
|
||||||
while(*ch != '\0'){
|
// while(*ch != '\0'){
|
||||||
if(!inBackQuote && *ch == '`'){
|
// if(!inBackQuote && *ch == '`'){
|
||||||
inBackQuote = true;
|
// inBackQuote = true;
|
||||||
ch++;
|
// ch++;
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if(inBackQuote && *ch == '`'){
|
// if(inBackQuote && *ch == '`'){
|
||||||
inBackQuote = false;
|
// inBackQuote = false;
|
||||||
ch++;
|
// ch++;
|
||||||
|
//
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if(!inBackQuote && *ch == '.'){
|
// if(!inBackQuote && *ch == '.'){
|
||||||
dotIndex ++;
|
// dotIndex ++;
|
||||||
if(dotIndex == 2){
|
// if(dotIndex == 2){
|
||||||
memmove(sql, ch + 1, strlen(ch + 1) + 1);
|
// memmove(sql, ch + 1, strlen(ch + 1) + 1);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
ch++;
|
// ch++;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) {
|
static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
SDeleteRes req = {0};
|
SDeleteRes req = {0};
|
||||||
|
@ -2867,9 +2867,9 @@ static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTbName(req.tableFName);
|
// getTbName(req.tableFName);
|
||||||
char sql[256] = {0};
|
char sql[256] = {0};
|
||||||
sprintf(sql, "delete from `%s` where `%s` >= %" PRId64" and `%s` <= %" PRId64, req.tableFName, "ts", req.skey, "ts", req.ekey);
|
sprintf(sql, "delete from `%s` where `%s` >= %" PRId64" and `%s` <= %" PRId64, req.tableFName, req.tsColName, req.skey, req.tsColName, req.ekey);
|
||||||
printf("delete sql:%s\n", sql);
|
printf("delete sql:%s\n", sql);
|
||||||
|
|
||||||
TAOS_RES* res = taos_query(taos, sql);
|
TAOS_RES* res = taos_query(taos, sql);
|
||||||
|
|
|
@ -5682,6 +5682,7 @@ int32_t tEncodeDeleteRes(SEncoder *pCoder, const SDeleteRes *pRes) {
|
||||||
if (tEncodeI64v(pCoder, pRes->affectedRows) < 0) return -1;
|
if (tEncodeI64v(pCoder, pRes->affectedRows) < 0) return -1;
|
||||||
|
|
||||||
if (tEncodeCStr(pCoder, pRes->tableFName) < 0) return -1;
|
if (tEncodeCStr(pCoder, pRes->tableFName) < 0) return -1;
|
||||||
|
if (tEncodeCStr(pCoder, pRes->tsColName) < 0) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5700,6 +5701,7 @@ int32_t tDecodeDeleteRes(SDecoder *pCoder, SDeleteRes *pRes) {
|
||||||
if (tDecodeI64v(pCoder, &pRes->affectedRows) < 0) return -1;
|
if (tDecodeI64v(pCoder, &pRes->affectedRows) < 0) return -1;
|
||||||
|
|
||||||
if (tDecodeCStrTo(pCoder, pRes->tableFName) < 0) return -1;
|
if (tDecodeCStrTo(pCoder, pRes->tableFName) < 0) return -1;
|
||||||
|
if (tDecodeCStrTo(pCoder, pRes->tsColName) < 0) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32_t tEncodeSMqDataRsp(SEncoder *pEncoder, const SMqDataRsp *pRsp) {
|
int32_t tEncodeSMqDataRsp(SEncoder *pEncoder, const SMqDataRsp *pRsp) {
|
||||||
|
|
|
@ -184,6 +184,7 @@ SArray *mmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_MND_BATCH_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_CFG, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_CFG, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -343,6 +343,7 @@ SArray *vmGetMsgHandles() {
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_UPDATE_TAG_VAL, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_UPDATE_TAG_VAL, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_CFG, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_CFG, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
|
if (dmSetMgmtHandle(pArray, TDMT_VND_BATCH_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLES_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLES_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_CANCEL_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_CANCEL_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_DROP_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
if (dmSetMgmtHandle(pArray, TDMT_SCH_DROP_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||||
|
|
|
@ -89,7 +89,7 @@ static void vmProcessStreamQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||||
int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, pMsg, pInfo);
|
int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, pMsg, pInfo);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
if (terrno != 0) code = terrno;
|
if (terrno != 0) code = terrno;
|
||||||
dGError("vgId:%d, msg:%p failed to stream since %s", pVnode->vgId, pMsg, terrstr());
|
dGError("vgId:%d, msg:%p failed to process stream since %s", pVnode->vgId, pMsg, terrstr());
|
||||||
vmSendRsp(pMsg, code);
|
vmSendRsp(pMsg, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,106 @@ int32_t mndProcessQueryMsg(SRpcMsg *pMsg) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t offset = 0;
|
||||||
|
int32_t rspSize = 0;
|
||||||
|
SBatchReq *batchReq = (SBatchReq*)pMsg->pCont;
|
||||||
|
int32_t msgNum = ntohl(batchReq->msgNum);
|
||||||
|
offset += sizeof(SBatchReq);
|
||||||
|
SBatchMsg req = {0};
|
||||||
|
SBatchRsp rsp = {0};
|
||||||
|
SRpcMsg reqMsg = *pMsg;
|
||||||
|
SRpcMsg rspMsg = {0};
|
||||||
|
void* pRsp = NULL;
|
||||||
|
SMnode *pMnode = pMsg->info.node;
|
||||||
|
|
||||||
|
SArray* batchRsp = taosArrayInit(msgNum, sizeof(SBatchRsp));
|
||||||
|
if (NULL == batchRsp) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < msgNum; ++i) {
|
||||||
|
req.msgType = ntohl(*(int32_t*)((char*)pMsg->pCont + offset));
|
||||||
|
offset += sizeof(req.msgType);
|
||||||
|
|
||||||
|
req.msgLen = ntohl(*(int32_t*)((char*)pMsg->pCont + offset));
|
||||||
|
offset += sizeof(req.msgLen);
|
||||||
|
|
||||||
|
req.msg = (char*)pMsg->pCont + offset;
|
||||||
|
offset += req.msgLen;
|
||||||
|
|
||||||
|
reqMsg.msgType = req.msgType;
|
||||||
|
reqMsg.pCont = req.msg;
|
||||||
|
reqMsg.contLen = req.msgLen;
|
||||||
|
reqMsg.info.rsp = NULL;
|
||||||
|
reqMsg.info.rspLen = 0;
|
||||||
|
|
||||||
|
MndMsgFp fp = pMnode->msgFp[TMSG_INDEX(req.msgType)];
|
||||||
|
if (fp == NULL) {
|
||||||
|
mError("msg:%p, failed to get msg handle, app:%p type:%s", pMsg, pMsg->info.ahandle, TMSG_INFO(pMsg->msgType));
|
||||||
|
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((*fp)(&reqMsg)) {
|
||||||
|
rsp.rspCode = terrno;
|
||||||
|
} else {
|
||||||
|
rsp.rspCode = 0;
|
||||||
|
}
|
||||||
|
rsp.reqType = reqMsg.msgType;
|
||||||
|
rsp.msgLen = reqMsg.info.rspLen;
|
||||||
|
rsp.msg = reqMsg.info.rsp;
|
||||||
|
|
||||||
|
taosArrayPush(batchRsp, &rsp);
|
||||||
|
|
||||||
|
rspSize += sizeof(rsp) + rsp.msgLen - POINTER_BYTES;
|
||||||
|
}
|
||||||
|
|
||||||
|
rspSize += sizeof(int32_t);
|
||||||
|
offset = 0;
|
||||||
|
|
||||||
|
pRsp = rpcMallocCont(rspSize);
|
||||||
|
if (pRsp == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(int32_t*)((char*)pRsp + offset) = htonl(msgNum);
|
||||||
|
offset += sizeof(msgNum);
|
||||||
|
for (int32_t i = 0; i < msgNum; ++i) {
|
||||||
|
SBatchRsp *p = taosArrayGet(batchRsp, i);
|
||||||
|
|
||||||
|
*(int32_t*)((char*)pRsp + offset) = htonl(p->reqType);
|
||||||
|
offset += sizeof(p->reqType);
|
||||||
|
*(int32_t*)((char*)pRsp + offset) = htonl(p->msgLen);
|
||||||
|
offset += sizeof(p->msgLen);
|
||||||
|
*(int32_t*)((char*)pRsp + offset) = htonl(p->rspCode);
|
||||||
|
offset += sizeof(p->rspCode);
|
||||||
|
memcpy((char*)pRsp + offset, p->msg, p->msgLen);
|
||||||
|
offset += p->msgLen;
|
||||||
|
|
||||||
|
rpcFreeCont(p->msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(batchRsp);
|
||||||
|
batchRsp = NULL;
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
|
||||||
|
pMsg->info.rsp = pRsp;
|
||||||
|
pMsg->info.rspLen = rspSize;
|
||||||
|
|
||||||
|
if (code) {
|
||||||
|
mError("mnd get batch meta failed cause of %s", tstrerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroyEx(batchRsp, tFreeSBatchRsp);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t mndInitQuery(SMnode *pMnode) {
|
int32_t mndInitQuery(SMnode *pMnode) {
|
||||||
if (qWorkerInit(NODE_TYPE_MNODE, MNODE_HANDLE, NULL, (void **)&pMnode->pQuery, &pMnode->msgCb) != 0) {
|
if (qWorkerInit(NODE_TYPE_MNODE, MNODE_HANDLE, NULL, (void **)&pMnode->pQuery, &pMnode->msgCb) != 0) {
|
||||||
mError("failed to init qworker in mnode since %s", terrstr());
|
mError("failed to init qworker in mnode since %s", terrstr());
|
||||||
|
@ -76,6 +176,7 @@ int32_t mndInitQuery(SMnode *pMnode) {
|
||||||
mndSetMsgHandle(pMnode, TDMT_SCH_MERGE_FETCH, mndProcessQueryMsg);
|
mndSetMsgHandle(pMnode, TDMT_SCH_MERGE_FETCH, mndProcessQueryMsg);
|
||||||
mndSetMsgHandle(pMnode, TDMT_SCH_DROP_TASK, mndProcessQueryMsg);
|
mndSetMsgHandle(pMnode, TDMT_SCH_DROP_TASK, mndProcessQueryMsg);
|
||||||
mndSetMsgHandle(pMnode, TDMT_SCH_QUERY_HEARTBEAT, mndProcessQueryMsg);
|
mndSetMsgHandle(pMnode, TDMT_SCH_QUERY_HEARTBEAT, mndProcessQueryMsg);
|
||||||
|
mndSetMsgHandle(pMnode, TDMT_MND_BATCH_META, mndProcessBatchMetaMsg);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -391,10 +391,12 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
|
||||||
// exec
|
// exec
|
||||||
pInnerTask->execType = TASK_EXEC__PIPE;
|
pInnerTask->execType = TASK_EXEC__PIPE;
|
||||||
|
|
||||||
|
#if 0
|
||||||
SDbObj* pSourceDb = mndAcquireDb(pMnode, pStream->sourceDb);
|
SDbObj* pSourceDb = mndAcquireDb(pMnode, pStream->sourceDb);
|
||||||
ASSERT(pDbObj != NULL);
|
ASSERT(pDbObj != NULL);
|
||||||
sdbRelease(pSdb, pSourceDb);
|
sdbRelease(pSdb, pSourceDb);
|
||||||
pInnerTask->numOfVgroups = pSourceDb->cfg.numOfVgroups;
|
pInnerTask->numOfVgroups = pSourceDb->cfg.numOfVgroups;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (tsSchedStreamToSnode) {
|
if (tsSchedStreamToSnode) {
|
||||||
SSnodeObj* pSnode = mndSchedFetchOneSnode(pMnode);
|
SSnodeObj* pSnode = mndSchedFetchOneSnode(pMnode);
|
||||||
|
|
|
@ -78,8 +78,9 @@ void vnodeBufPoolReset(SVBufPool* pPool);
|
||||||
// vnodeQuery.c
|
// vnodeQuery.c
|
||||||
int32_t vnodeQueryOpen(SVnode* pVnode);
|
int32_t vnodeQueryOpen(SVnode* pVnode);
|
||||||
void vnodeQueryClose(SVnode* pVnode);
|
void vnodeQueryClose(SVnode* pVnode);
|
||||||
int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg);
|
int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg, bool direct);
|
||||||
int vnodeGetTableCfg(SVnode* pVnode, SRpcMsg* pMsg);
|
int vnodeGetTableCfg(SVnode* pVnode, SRpcMsg* pMsg, bool direct);
|
||||||
|
int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg);
|
||||||
|
|
||||||
// vnodeCommit.c
|
// vnodeCommit.c
|
||||||
int32_t vnodeBegin(SVnode* pVnode);
|
int32_t vnodeBegin(SVnode* pVnode);
|
||||||
|
|
|
@ -611,8 +611,8 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
smaDebug("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " version:%"PRIi64, SMA_VID(pSma),
|
smaDebug("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " version:%" PRIi64,
|
||||||
suid, pItem->level, output->info.version);
|
SMA_VID(pSma), suid, pItem->level, output->info.version);
|
||||||
|
|
||||||
taosMemoryFreeClear(pReq);
|
taosMemoryFreeClear(pReq);
|
||||||
taosArrayClear(pResult);
|
taosArrayClear(pResult);
|
||||||
|
@ -644,7 +644,7 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType
|
||||||
smaDebug("vgId:%d, execute rsma %" PRIi8 " task for qTaskInfo:%p suid:%" PRIu64, SMA_VID(pSma), level,
|
smaDebug("vgId:%d, execute rsma %" PRIi8 " task for qTaskInfo:%p suid:%" PRIu64, SMA_VID(pSma), level,
|
||||||
pItem->taskInfo, suid);
|
pItem->taskInfo, suid);
|
||||||
|
|
||||||
if (qSetStreamInput(pItem->taskInfo, pMsg, inputType, true) < 0) { // INPUT__DATA_SUBMIT
|
if (qSetMultiStreamInput(pItem->taskInfo, pMsg, 1, inputType) < 0) { // INPUT__DATA_SUBMIT
|
||||||
smaError("vgId:%d, rsma % " PRIi8 " qSetStreamInput failed since %s", SMA_VID(pSma), level, tstrerror(terrno));
|
smaError("vgId:%d, rsma % " PRIi8 " qSetStreamInput failed since %s", SMA_VID(pSma), level, tstrerror(terrno));
|
||||||
return TSDB_CODE_FAILED;
|
return TSDB_CODE_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -1329,7 +1329,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
||||||
tdRefRSmaInfo(pSma, pRSmaInfo);
|
tdRefRSmaInfo(pSma, pRSmaInfo);
|
||||||
|
|
||||||
SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL};
|
SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL};
|
||||||
qSetStreamInput(pItem->taskInfo, &dataBlock, STREAM_INPUT__DATA_BLOCK, false);
|
qSetMultiStreamInput(pItem->taskInfo, &dataBlock, 1, STREAM_INPUT__DATA_BLOCK);
|
||||||
tdRSmaFetchAndSubmitResult(pItem, pRSmaInfo->pTSchema, pRSmaInfo->suid, pStat, STREAM_INPUT__DATA_BLOCK);
|
tdRSmaFetchAndSubmitResult(pItem, pRSmaInfo->pTSchema, pRSmaInfo->suid, pStat, STREAM_INPUT__DATA_BLOCK);
|
||||||
|
|
||||||
tdUnRefRSmaInfo(pSma, pRSmaInfo);
|
tdUnRefRSmaInfo(pSma, pRSmaInfo);
|
||||||
|
@ -1356,4 +1356,4 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
||||||
|
|
||||||
_end:
|
_end:
|
||||||
tdReleaseSmaRef(smaMgmt.rsetId, pItem->refId, __func__, __LINE__);
|
tdReleaseSmaRef(smaMgmt.rsetId, pItem->refId, __func__, __LINE__);
|
||||||
}
|
}
|
||||||
|
|
|
@ -653,7 +653,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
|
||||||
} else {
|
} else {
|
||||||
SReadHandle mgHandle = {
|
SReadHandle mgHandle = {
|
||||||
.vnode = NULL,
|
.vnode = NULL,
|
||||||
.numOfVgroups = pTask->numOfVgroups,
|
.numOfVgroups = (int32_t)taosArrayGetSize(pTask->childEpInfo),
|
||||||
};
|
};
|
||||||
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &mgHandle);
|
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &mgHandle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ int vnodeQueryOpen(SVnode *pVnode) {
|
||||||
|
|
||||||
void vnodeQueryClose(SVnode *pVnode) { qWorkerDestroy((void **)&pVnode->pQuery); }
|
void vnodeQueryClose(SVnode *pVnode) { qWorkerDestroy((void **)&pVnode->pQuery); }
|
||||||
|
|
||||||
int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||||
STableInfoReq infoReq = {0};
|
STableInfoReq infoReq = {0};
|
||||||
STableMetaRsp metaRsp = {0};
|
STableMetaRsp metaRsp = {0};
|
||||||
SMetaReader mer1 = {0};
|
SMetaReader mer1 = {0};
|
||||||
|
@ -99,7 +99,12 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRsp = rpcMallocCont(rspLen);
|
if (direct) {
|
||||||
|
pRsp = rpcMallocCont(rspLen);
|
||||||
|
} else {
|
||||||
|
pRsp = taosMemoryCalloc(1, rspLen);
|
||||||
|
}
|
||||||
|
|
||||||
if (pRsp == NULL) {
|
if (pRsp == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
@ -117,15 +122,19 @@ _exit:
|
||||||
qError("get table %s meta failed cause of %s", infoReq.tbName, tstrerror(code));
|
qError("get table %s meta failed cause of %s", infoReq.tbName, tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
tmsgSendRsp(&rpcMsg);
|
if (direct) {
|
||||||
|
tmsgSendRsp(&rpcMsg);
|
||||||
|
} else {
|
||||||
|
*pMsg = rpcMsg;
|
||||||
|
}
|
||||||
|
|
||||||
taosMemoryFree(metaRsp.pSchemas);
|
taosMemoryFree(metaRsp.pSchemas);
|
||||||
metaReaderClear(&mer2);
|
metaReaderClear(&mer2);
|
||||||
metaReaderClear(&mer1);
|
metaReaderClear(&mer1);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg) {
|
int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||||
STableCfgReq cfgReq = {0};
|
STableCfgReq cfgReq = {0};
|
||||||
STableCfgRsp cfgRsp = {0};
|
STableCfgRsp cfgRsp = {0};
|
||||||
SMetaReader mer1 = {0};
|
SMetaReader mer1 = {0};
|
||||||
|
@ -209,7 +218,12 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRsp = rpcMallocCont(rspLen);
|
if (direct) {
|
||||||
|
pRsp = rpcMallocCont(rspLen);
|
||||||
|
} else {
|
||||||
|
pRsp = taosMemoryCalloc(1, rspLen);
|
||||||
|
}
|
||||||
|
|
||||||
if (pRsp == NULL) {
|
if (pRsp == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
|
@ -227,14 +241,124 @@ _exit:
|
||||||
qError("get table %s cfg failed cause of %s", cfgReq.tbName, tstrerror(code));
|
qError("get table %s cfg failed cause of %s", cfgReq.tbName, tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
tmsgSendRsp(&rpcMsg);
|
if (direct) {
|
||||||
|
tmsgSendRsp(&rpcMsg);
|
||||||
|
} else {
|
||||||
|
*pMsg = rpcMsg;
|
||||||
|
}
|
||||||
|
|
||||||
tFreeSTableCfgRsp(&cfgRsp);
|
tFreeSTableCfgRsp(&cfgRsp);
|
||||||
metaReaderClear(&mer2);
|
metaReaderClear(&mer2);
|
||||||
metaReaderClear(&mer1);
|
metaReaderClear(&mer1);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t offset = 0;
|
||||||
|
int32_t rspSize = 0;
|
||||||
|
SBatchReq *batchReq = (SBatchReq*)pMsg->pCont;
|
||||||
|
int32_t msgNum = ntohl(batchReq->msgNum);
|
||||||
|
offset += sizeof(SBatchReq);
|
||||||
|
SBatchMsg req = {0};
|
||||||
|
SBatchRsp rsp = {0};
|
||||||
|
SRpcMsg reqMsg = *pMsg;
|
||||||
|
SRpcMsg rspMsg = {0};
|
||||||
|
void* pRsp = NULL;
|
||||||
|
|
||||||
|
SArray* batchRsp = taosArrayInit(msgNum, sizeof(SBatchRsp));
|
||||||
|
if (NULL == batchRsp) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < msgNum; ++i) {
|
||||||
|
req.msgType = ntohl(*(int32_t*)((char*)pMsg->pCont + offset));
|
||||||
|
offset += sizeof(req.msgType);
|
||||||
|
|
||||||
|
req.msgLen = ntohl(*(int32_t*)((char*)pMsg->pCont + offset));
|
||||||
|
offset += sizeof(req.msgLen);
|
||||||
|
|
||||||
|
req.msg = (char*)pMsg->pCont + offset;
|
||||||
|
offset += req.msgLen;
|
||||||
|
|
||||||
|
reqMsg.msgType = req.msgType;
|
||||||
|
reqMsg.pCont = req.msg;
|
||||||
|
reqMsg.contLen = req.msgLen;
|
||||||
|
|
||||||
|
switch (req.msgType) {
|
||||||
|
case TDMT_VND_TABLE_META:
|
||||||
|
vnodeGetTableMeta(pVnode, &reqMsg, false);
|
||||||
|
break;
|
||||||
|
case TDMT_VND_TABLE_CFG:
|
||||||
|
vnodeGetTableCfg(pVnode, &reqMsg, false);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qError("invalid req msgType %d", req.msgType);
|
||||||
|
reqMsg.code = TSDB_CODE_INVALID_MSG;
|
||||||
|
reqMsg.pCont = NULL;
|
||||||
|
reqMsg.contLen = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
rsp.reqType = reqMsg.msgType;
|
||||||
|
rsp.msgLen = reqMsg.contLen;
|
||||||
|
rsp.rspCode = reqMsg.code;
|
||||||
|
rsp.msg = reqMsg.pCont;
|
||||||
|
|
||||||
|
taosArrayPush(batchRsp, &rsp);
|
||||||
|
|
||||||
|
rspSize += sizeof(rsp) + rsp.msgLen - POINTER_BYTES;
|
||||||
|
}
|
||||||
|
|
||||||
|
rspSize += sizeof(int32_t);
|
||||||
|
offset = 0;
|
||||||
|
|
||||||
|
pRsp = rpcMallocCont(rspSize);
|
||||||
|
if (pRsp == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(int32_t*)((char*)pRsp + offset) = htonl(msgNum);
|
||||||
|
offset += sizeof(msgNum);
|
||||||
|
for (int32_t i = 0; i < msgNum; ++i) {
|
||||||
|
SBatchRsp *p = taosArrayGet(batchRsp, i);
|
||||||
|
|
||||||
|
*(int32_t*)((char*)pRsp + offset) = htonl(p->reqType);
|
||||||
|
offset += sizeof(p->reqType);
|
||||||
|
*(int32_t*)((char*)pRsp + offset) = htonl(p->msgLen);
|
||||||
|
offset += sizeof(p->msgLen);
|
||||||
|
*(int32_t*)((char*)pRsp + offset) = htonl(p->rspCode);
|
||||||
|
offset += sizeof(p->rspCode);
|
||||||
|
memcpy((char*)pRsp + offset, p->msg, p->msgLen);
|
||||||
|
offset += p->msgLen;
|
||||||
|
|
||||||
|
taosMemoryFreeClear(p->msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(batchRsp);
|
||||||
|
batchRsp = NULL;
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
|
||||||
|
rspMsg.info = pMsg->info;
|
||||||
|
rspMsg.pCont = pRsp;
|
||||||
|
rspMsg.contLen = rspSize;
|
||||||
|
rspMsg.code = code;
|
||||||
|
rspMsg.msgType = pMsg->msgType;
|
||||||
|
|
||||||
|
if (code) {
|
||||||
|
qError("vnd get batch meta failed cause of %s", tstrerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroyEx(batchRsp, tFreeSBatchRsp);
|
||||||
|
|
||||||
|
tmsgSendRsp(&rspMsg);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
|
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
|
||||||
pLoad->vgId = TD_VID(pVnode);
|
pLoad->vgId = TD_VID(pVnode);
|
||||||
pLoad->syncState = syncGetMyRole(pVnode->sync);
|
pLoad->syncState = syncGetMyRole(pVnode->sync);
|
||||||
|
|
|
@ -298,7 +298,7 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
||||||
vTrace("message in fetch queue is processing");
|
vTrace("message in fetch queue is processing");
|
||||||
if ((pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_VND_TABLE_META ||
|
if ((pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_VND_TABLE_META ||
|
||||||
pMsg->msgType == TDMT_VND_TABLE_CFG) &&
|
pMsg->msgType == TDMT_VND_TABLE_CFG || pMsg->msgType == TDMT_VND_BATCH_META) &&
|
||||||
!vnodeIsLeader(pVnode)) {
|
!vnodeIsLeader(pVnode)) {
|
||||||
vnodeRedirectRpcMsg(pVnode, pMsg);
|
vnodeRedirectRpcMsg(pVnode, pMsg);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -320,9 +320,11 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
||||||
case TDMT_SCH_QUERY_HEARTBEAT:
|
case TDMT_SCH_QUERY_HEARTBEAT:
|
||||||
return qWorkerProcessHbMsg(pVnode, pVnode->pQuery, pMsg, 0);
|
return qWorkerProcessHbMsg(pVnode, pVnode->pQuery, pMsg, 0);
|
||||||
case TDMT_VND_TABLE_META:
|
case TDMT_VND_TABLE_META:
|
||||||
return vnodeGetTableMeta(pVnode, pMsg);
|
return vnodeGetTableMeta(pVnode, pMsg, true);
|
||||||
case TDMT_VND_TABLE_CFG:
|
case TDMT_VND_TABLE_CFG:
|
||||||
return vnodeGetTableCfg(pVnode, pMsg);
|
return vnodeGetTableCfg(pVnode, pMsg, true);
|
||||||
|
case TDMT_VND_BATCH_META:
|
||||||
|
return vnodeGetBatchMeta(pVnode, pMsg);
|
||||||
case TDMT_VND_CONSUME:
|
case TDMT_VND_CONSUME:
|
||||||
return tqProcessPollReq(pVnode->pTq, pMsg);
|
return tqProcessPollReq(pVnode->pTq, pMsg);
|
||||||
case TDMT_STREAM_TASK_RUN:
|
case TDMT_STREAM_TASK_RUN:
|
||||||
|
|
|
@ -31,6 +31,7 @@ extern "C" {
|
||||||
#define CTG_DEFAULT_RENT_SECOND 10
|
#define CTG_DEFAULT_RENT_SECOND 10
|
||||||
#define CTG_DEFAULT_RENT_SLOT_SIZE 10
|
#define CTG_DEFAULT_RENT_SLOT_SIZE 10
|
||||||
#define CTG_DEFAULT_MAX_RETRY_TIMES 3
|
#define CTG_DEFAULT_MAX_RETRY_TIMES 3
|
||||||
|
#define CTG_DEFAULT_BATCH_NUM 64
|
||||||
|
|
||||||
#define CTG_RENT_SLOT_SECOND 1.5
|
#define CTG_RENT_SLOT_SECOND 1.5
|
||||||
|
|
||||||
|
@ -38,6 +39,8 @@ extern "C" {
|
||||||
|
|
||||||
#define CTG_ERR_CODE_TABLE_NOT_EXIST TSDB_CODE_PAR_TABLE_NOT_EXIST
|
#define CTG_ERR_CODE_TABLE_NOT_EXIST TSDB_CODE_PAR_TABLE_NOT_EXIST
|
||||||
|
|
||||||
|
#define CTG_BATCH_FETCH 1
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CTG_READ = 1,
|
CTG_READ = 1,
|
||||||
CTG_WRITE,
|
CTG_WRITE,
|
||||||
|
@ -200,8 +203,20 @@ typedef struct SCatalog {
|
||||||
SCtgRentMgmt stbRent;
|
SCtgRentMgmt stbRent;
|
||||||
} SCatalog;
|
} SCatalog;
|
||||||
|
|
||||||
|
typedef struct SCtgBatch {
|
||||||
|
int32_t batchId;
|
||||||
|
int32_t msgType;
|
||||||
|
int32_t msgSize;
|
||||||
|
SArray* pMsgs;
|
||||||
|
SRequestConnInfo conn;
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
SArray* pTaskIds;
|
||||||
|
} SCtgBatch;
|
||||||
|
|
||||||
typedef struct SCtgJob {
|
typedef struct SCtgJob {
|
||||||
int64_t refId;
|
int64_t refId;
|
||||||
|
int32_t batchId;
|
||||||
|
SHashObj* pBatchs;
|
||||||
SArray* pTasks;
|
SArray* pTasks;
|
||||||
int32_t taskDone;
|
int32_t taskDone;
|
||||||
SMetaData jobRes;
|
SMetaData jobRes;
|
||||||
|
@ -236,6 +251,16 @@ typedef struct SCtgMsgCtx {
|
||||||
char* target;
|
char* target;
|
||||||
} SCtgMsgCtx;
|
} SCtgMsgCtx;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct SCtgTaskCallbackParam {
|
||||||
|
uint64_t queryId;
|
||||||
|
int64_t refId;
|
||||||
|
SArray* taskId;
|
||||||
|
int32_t reqType;
|
||||||
|
int32_t batchId;
|
||||||
|
} SCtgTaskCallbackParam;
|
||||||
|
|
||||||
|
|
||||||
typedef struct SCtgTask SCtgTask;
|
typedef struct SCtgTask SCtgTask;
|
||||||
typedef int32_t (*ctgSubTaskCbFp)(SCtgTask*);
|
typedef int32_t (*ctgSubTaskCbFp)(SCtgTask*);
|
||||||
|
|
||||||
|
@ -258,6 +283,7 @@ typedef struct SCtgTask {
|
||||||
SRWLatch lock;
|
SRWLatch lock;
|
||||||
SArray* pParents;
|
SArray* pParents;
|
||||||
SCtgSubRes subRes;
|
SCtgSubRes subRes;
|
||||||
|
SHashObj* pBatchs;
|
||||||
} SCtgTask;
|
} SCtgTask;
|
||||||
|
|
||||||
typedef int32_t (*ctgInitTaskFp)(SCtgJob*, int32_t, void*);
|
typedef int32_t (*ctgInitTaskFp)(SCtgJob*, int32_t, void*);
|
||||||
|
@ -618,6 +644,7 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SNa
|
||||||
int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableCfg **out, SCtgTask* pTask);
|
int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableCfg **out, SCtgTask* pTask);
|
||||||
int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg **out, SCtgTask* pTask);
|
int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg **out, SCtgTask* pTask);
|
||||||
int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, char **out, SCtgTask* pTask);
|
int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, char **out, SCtgTask* pTask);
|
||||||
|
int32_t ctgLaunchBatchs(SCatalog* pCtg, SCtgJob *pJob, SHashObj* pBatchs);
|
||||||
|
|
||||||
int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, void* param);
|
int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, void* param);
|
||||||
int32_t ctgLaunchJob(SCtgJob *pJob);
|
int32_t ctgLaunchJob(SCtgJob *pJob);
|
||||||
|
@ -626,6 +653,9 @@ int32_t ctgLaunchSubTask(SCtgTask *pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp,
|
||||||
int32_t ctgGetTbCfgCb(SCtgTask *pTask);
|
int32_t ctgGetTbCfgCb(SCtgTask *pTask);
|
||||||
void ctgFreeHandle(SCatalog* pCatalog);
|
void ctgFreeHandle(SCatalog* pCatalog);
|
||||||
|
|
||||||
|
void ctgFreeMsgSendParam(void* param);
|
||||||
|
void ctgFreeBatch(SCtgBatch *pBatch);
|
||||||
|
void ctgFreeBatchs(SHashObj *pBatchs);
|
||||||
int32_t ctgCloneVgInfo(SDBVgInfo *src, SDBVgInfo **dst);
|
int32_t ctgCloneVgInfo(SDBVgInfo *src, SDBVgInfo **dst);
|
||||||
int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput);
|
int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput);
|
||||||
int32_t ctgGenerateVgList(SCatalog *pCtg, SHashObj *vgHash, SArray** pList);
|
int32_t ctgGenerateVgList(SCatalog *pCtg, SHashObj *vgHash, SArray** pList);
|
||||||
|
@ -642,7 +672,7 @@ int32_t ctgDbVgVersionSearchCompare(const void* key1, const void* key2);
|
||||||
void ctgFreeSTableMetaOutput(STableMetaOutput* pOutput);
|
void ctgFreeSTableMetaOutput(STableMetaOutput* pOutput);
|
||||||
int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* target);
|
int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* target);
|
||||||
char * ctgTaskTypeStr(CTG_TASK_TYPE type);
|
char * ctgTaskTypeStr(CTG_TASK_TYPE type);
|
||||||
int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, SCtgTask* pTask);
|
int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, char* dbFName, int32_t vgId);
|
||||||
int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes);
|
int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes);
|
||||||
void ctgFreeSTableIndex(void *info);
|
void ctgFreeSTableIndex(void *info);
|
||||||
void ctgClearSubTaskRes(SCtgSubRes *pRes);
|
void ctgClearSubTaskRes(SCtgSubRes *pRes);
|
||||||
|
|
|
@ -20,12 +20,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct SCtgTaskCallbackParam {
|
|
||||||
uint64_t queryId;
|
|
||||||
int64_t refId;
|
|
||||||
uint64_t taskId;
|
|
||||||
int32_t reqType;
|
|
||||||
} SCtgTaskCallbackParam;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -473,8 +473,15 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const
|
||||||
pJob->tbCfgNum = tbCfgNum;
|
pJob->tbCfgNum = tbCfgNum;
|
||||||
pJob->svrVerNum = svrVerNum;
|
pJob->svrVerNum = svrVerNum;
|
||||||
|
|
||||||
pJob->pTasks = taosArrayInit(taskNum, sizeof(SCtgTask));
|
#if CTG_BATCH_FETCH
|
||||||
|
pJob->pBatchs = taosHashInit(CTG_DEFAULT_BATCH_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||||
|
if (NULL == pJob->pBatchs) {
|
||||||
|
ctgError("taosHashInit %d batch failed", CTG_DEFAULT_BATCH_NUM);
|
||||||
|
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pJob->pTasks = taosArrayInit(taskNum, sizeof(SCtgTask));
|
||||||
if (NULL == pJob->pTasks) {
|
if (NULL == pJob->pTasks) {
|
||||||
ctgError("taosArrayInit %d tasks failed", taskNum);
|
ctgError("taosArrayInit %d tasks failed", taskNum);
|
||||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
@ -560,7 +567,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
taosMemoryFreeClear(*job);
|
ctgFreeJob(*job);
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -776,7 +783,8 @@ int32_t ctgCallSubCb(SCtgTask *pTask) {
|
||||||
pParent->subRes.code = code;
|
pParent->subRes.code = code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pParent->pBatchs = pTask->pBatchs;
|
||||||
CTG_ERR_JRET(pParent->subRes.fp(pParent));
|
CTG_ERR_JRET(pParent->subRes.fp(pParent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -872,7 +880,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *
|
||||||
SVgroupInfo vgInfo = {0};
|
SVgroupInfo vgInfo = {0};
|
||||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, ctx->pName, &vgInfo));
|
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, ctx->pName, &vgInfo));
|
||||||
|
|
||||||
ctgDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(ctx->pName), ctx->flag);
|
ctgDebug("will refresh tbmeta, supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(ctx->pName), ctx->flag);
|
||||||
|
|
||||||
ctx->vgId = vgInfo.vgId;
|
ctx->vgId = vgInfo.vgId;
|
||||||
CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, ctx->pName, &vgInfo, NULL, pTask));
|
CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, ctx->pName, &vgInfo, NULL, pTask));
|
||||||
|
@ -890,7 +898,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctgError("no tbmeta got, tbNmae:%s", tNameGetTableName(ctx->pName));
|
ctgError("no tbmeta got, tbName:%s", tNameGetTableName(ctx->pName));
|
||||||
ctgRemoveTbMetaFromCache(pCtg, ctx->pName, false);
|
ctgRemoveTbMetaFromCache(pCtg, ctx->pName, false);
|
||||||
|
|
||||||
CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST);
|
CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST);
|
||||||
|
@ -1653,6 +1661,7 @@ int32_t ctgSetSubTaskCb(SCtgTask *pSub, SCtgTask *pTask) {
|
||||||
if (CTG_TASK_DONE == pSub->status) {
|
if (CTG_TASK_DONE == pSub->status) {
|
||||||
pTask->subRes.code = pSub->code;
|
pTask->subRes.code = pSub->code;
|
||||||
CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].cloneFp)(pSub, &pTask->subRes.res));
|
CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].cloneFp)(pSub, &pTask->subRes.res));
|
||||||
|
pTask->pBatchs = pSub->pBatchs;
|
||||||
CTG_ERR_JRET(pTask->subRes.fp(pTask));
|
CTG_ERR_JRET(pTask->subRes.fp(pTask));
|
||||||
} else {
|
} else {
|
||||||
if (NULL == pSub->pParents) {
|
if (NULL == pSub->pParents) {
|
||||||
|
@ -1690,6 +1699,7 @@ int32_t ctgLaunchSubTask(SCtgTask *pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp,
|
||||||
CTG_ERR_RET(ctgSetSubTaskCb(pSub, pTask));
|
CTG_ERR_RET(ctgSetSubTaskCb(pSub, pTask));
|
||||||
|
|
||||||
if (newTask) {
|
if (newTask) {
|
||||||
|
pSub->pBatchs = pTask->pBatchs;
|
||||||
CTG_ERR_RET((*gCtgAsyncFps[pSub->type].launchFp)(pSub));
|
CTG_ERR_RET((*gCtgAsyncFps[pSub->type].launchFp)(pSub));
|
||||||
pSub->status = CTG_TASK_LAUNCHED;
|
pSub->status = CTG_TASK_LAUNCHED;
|
||||||
}
|
}
|
||||||
|
@ -1702,9 +1712,11 @@ int32_t ctgLaunchJob(SCtgJob *pJob) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < taskNum; ++i) {
|
for (int32_t i = 0; i < taskNum; ++i) {
|
||||||
SCtgTask *pTask = taosArrayGet(pJob->pTasks, i);
|
SCtgTask *pTask = taosArrayGet(pJob->pTasks, i);
|
||||||
|
pTask->pBatchs = pJob->pBatchs;
|
||||||
|
|
||||||
qDebug("QID:0x%" PRIx64 " ctg launch [%dth] task", pJob->queryId, pTask->taskId);
|
qDebug("QID:0x%" PRIx64 " ctg launch [%dth] task", pJob->queryId, pTask->taskId);
|
||||||
CTG_ERR_RET((*gCtgAsyncFps[pTask->type].launchFp)(pTask));
|
CTG_ERR_RET((*gCtgAsyncFps[pTask->type].launchFp)(pTask));
|
||||||
|
|
||||||
pTask->status = CTG_TASK_LAUNCHED;
|
pTask->status = CTG_TASK_LAUNCHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1712,6 +1724,10 @@ int32_t ctgLaunchJob(SCtgJob *pJob) {
|
||||||
qDebug("QID:0x%" PRIx64 " ctg call user callback with rsp %s", pJob->queryId, tstrerror(pJob->jobResCode));
|
qDebug("QID:0x%" PRIx64 " ctg call user callback with rsp %s", pJob->queryId, tstrerror(pJob->jobResCode));
|
||||||
|
|
||||||
taosAsyncExec(ctgCallUserCb, pJob, NULL);
|
taosAsyncExec(ctgCallUserCb, pJob, NULL);
|
||||||
|
#if CTG_BATCH_FETCH
|
||||||
|
} else {
|
||||||
|
ctgLaunchBatchs(pJob->pCtg, pJob, pJob->pBatchs);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -18,9 +18,67 @@
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
#include "catalogInt.h"
|
#include "catalogInt.h"
|
||||||
#include "systable.h"
|
#include "systable.h"
|
||||||
#include "ctgRemote.h"
|
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
|
|
||||||
|
int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBuf *pMsg, int32_t rspCode) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SArray* pTaskId = cbParam->taskId;
|
||||||
|
SCatalog* pCtg = pJob->pCtg;
|
||||||
|
int32_t taskNum = taosArrayGetSize(pTaskId);
|
||||||
|
SDataBuf taskMsg = *pMsg;
|
||||||
|
int32_t offset = 0;
|
||||||
|
int32_t msgNum = (TSDB_CODE_SUCCESS == rspCode && pMsg->pData && (pMsg->len > 0)) ? ntohl(*(int32_t*)pMsg->pData) : 0;
|
||||||
|
ASSERT(taskNum == msgNum || 0 == msgNum);
|
||||||
|
|
||||||
|
ctgDebug("QID:0x%" PRIx64 " ctg got batch %d rsp %s", pJob->queryId, cbParam->batchId, TMSG_INFO(cbParam->reqType + 1));
|
||||||
|
|
||||||
|
offset += sizeof(msgNum);
|
||||||
|
SBatchRsp rsp = {0};
|
||||||
|
SHashObj* pBatchs = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||||
|
if (NULL == pBatchs) {
|
||||||
|
ctgError("taosHashInit %d batch failed", taskNum);
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < taskNum; ++i) {
|
||||||
|
int32_t* taskId = taosArrayGet(pTaskId, i);
|
||||||
|
SCtgTask *pTask = taosArrayGet(pJob->pTasks, *taskId);
|
||||||
|
if (msgNum > 0) {
|
||||||
|
rsp.reqType = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
|
||||||
|
offset += sizeof(rsp.reqType);
|
||||||
|
rsp.msgLen = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
|
||||||
|
offset += sizeof(rsp.msgLen);
|
||||||
|
rsp.rspCode = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
|
||||||
|
offset += sizeof(rsp.rspCode);
|
||||||
|
rsp.msg = ((char*)pMsg->pData) + offset;
|
||||||
|
offset += rsp.msgLen;
|
||||||
|
|
||||||
|
taskMsg.msgType = rsp.reqType;
|
||||||
|
taskMsg.pData = rsp.msg;
|
||||||
|
taskMsg.len = rsp.msgLen;
|
||||||
|
} else {
|
||||||
|
rsp.reqType = -1;
|
||||||
|
taskMsg.msgType = -1;
|
||||||
|
taskMsg.pData = NULL;
|
||||||
|
taskMsg.len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pTask->pBatchs = pBatchs;
|
||||||
|
|
||||||
|
ctgDebug("QID:0x%" PRIx64 " ctg task %d start to handle rsp %s", pJob->queryId, pTask->taskId, TMSG_INFO(taskMsg.msgType + 1));
|
||||||
|
|
||||||
|
(*gCtgAsyncFps[pTask->type].handleRspFp)(pTask, rsp.reqType, &taskMsg, (rsp.rspCode ? rsp.rspCode : rspCode));
|
||||||
|
}
|
||||||
|
|
||||||
|
CTG_ERR_JRET(ctgLaunchBatchs(pJob->pCtg, pJob, pBatchs));
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
ctgFreeBatchs(pBatchs);
|
||||||
|
CTG_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, int32_t rspCode, char* target) {
|
int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, int32_t rspCode, char* target) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -233,6 +291,11 @@ int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
if (TSDB_CODE_SUCCESS != rspCode) {
|
||||||
|
qError("Got error rsp, error:%s", tstrerror(rspCode));
|
||||||
|
CTG_ERR_RET(rspCode);
|
||||||
|
}
|
||||||
|
|
||||||
qError("invalid req type %s", TMSG_INFO(reqType));
|
qError("invalid req type %s", TMSG_INFO(reqType));
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -254,12 +317,32 @@ int32_t ctgHandleMsgCallback(void *param, SDataBuf *pMsg, int32_t rspCode) {
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCtgTask *pTask = taosArrayGet(pJob->pTasks, cbParam->taskId);
|
SCatalog* pCtg = pJob->pCtg;
|
||||||
|
|
||||||
qDebug("QID:0x%" PRIx64 " ctg task %d start to handle rsp %s", pJob->queryId, pTask->taskId, TMSG_INFO(cbParam->reqType + 1));
|
if (TDMT_VND_BATCH_META == cbParam->reqType || TDMT_MND_BATCH_META == cbParam->reqType) {
|
||||||
|
CTG_ERR_JRET(ctgHandleBatchRsp(pJob, cbParam, pMsg, rspCode));
|
||||||
|
} else {
|
||||||
|
int32_t *taskId = taosArrayGet(cbParam->taskId, 0);
|
||||||
|
SCtgTask *pTask = taosArrayGet(pJob->pTasks, *taskId);
|
||||||
|
|
||||||
|
qDebug("QID:0x%" PRIx64 " ctg task %d start to handle rsp %s", pJob->queryId, pTask->taskId, TMSG_INFO(cbParam->reqType + 1));
|
||||||
|
|
||||||
|
#if CTG_BATCH_FETCH
|
||||||
|
SHashObj* pBatchs = taosHashInit(CTG_DEFAULT_BATCH_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||||
|
if (NULL == pBatchs) {
|
||||||
|
ctgError("taosHashInit %d batch failed", CTG_DEFAULT_BATCH_NUM);
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
pTask->pBatchs = pBatchs;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].handleRspFp)(pTask, cbParam->reqType, pMsg, rspCode));
|
||||||
|
|
||||||
|
#if CTG_BATCH_FETCH
|
||||||
|
CTG_ERR_JRET(ctgLaunchBatchs(pJob->pCtg, pJob, pBatchs));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].handleRspFp)(pTask, cbParam->reqType, pMsg, rspCode));
|
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFree(pMsg->pData);
|
||||||
|
@ -272,12 +355,12 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgMakeMsgSendInfo(SCtgTask* pTask, int32_t msgType, SMsgSendInfo **pMsgSendInfo) {
|
int32_t ctgMakeMsgSendInfo(SCtgJob* pJob, SArray* pTaskId, int32_t batchId, int32_t msgType, SMsgSendInfo **pMsgSendInfo) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SMsgSendInfo *msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
SMsgSendInfo *msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||||
if (NULL == msgSendInfo) {
|
if (NULL == msgSendInfo) {
|
||||||
qError("calloc %d failed", (int32_t)sizeof(SMsgSendInfo));
|
qError("calloc %d failed", (int32_t)sizeof(SMsgSendInfo));
|
||||||
CTG_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
CTG_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCtgTaskCallbackParam *param = taosMemoryCalloc(1, sizeof(SCtgTaskCallbackParam));
|
SCtgTaskCallbackParam *param = taosMemoryCalloc(1, sizeof(SCtgTaskCallbackParam));
|
||||||
|
@ -287,12 +370,13 @@ int32_t ctgMakeMsgSendInfo(SCtgTask* pTask, int32_t msgType, SMsgSendInfo **pMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
param->reqType = msgType;
|
param->reqType = msgType;
|
||||||
param->queryId = pTask->pJob->queryId;
|
param->queryId = pJob->queryId;
|
||||||
param->refId = pTask->pJob->refId;
|
param->refId = pJob->refId;
|
||||||
param->taskId = pTask->taskId;
|
param->taskId = pTaskId;
|
||||||
|
param->batchId = batchId;
|
||||||
|
|
||||||
msgSendInfo->param = param;
|
msgSendInfo->param = param;
|
||||||
msgSendInfo->paramFreeFp = taosMemoryFree;
|
msgSendInfo->paramFreeFp = ctgFreeMsgSendParam;
|
||||||
msgSendInfo->fp = ctgHandleMsgCallback;
|
msgSendInfo->fp = ctgHandleMsgCallback;
|
||||||
|
|
||||||
*pMsgSendInfo = msgSendInfo;
|
*pMsgSendInfo = msgSendInfo;
|
||||||
|
@ -301,18 +385,19 @@ int32_t ctgMakeMsgSendInfo(SCtgTask* pTask, int32_t msgType, SMsgSendInfo **pMsg
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
taosMemoryFree(param);
|
taosArrayDestroy(pTaskId);
|
||||||
taosMemoryFree(msgSendInfo);
|
destroySendMsgInfo(msgSendInfo);
|
||||||
|
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ctgAsyncSendMsg(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTask* pTask, int32_t msgType, void *msg, uint32_t msgSize) {
|
int32_t ctgAsyncSendMsg(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob* pJob, SArray* pTaskId,
|
||||||
|
int32_t batchId, char* dbFName, int32_t vgId, int32_t msgType, void *msg, uint32_t msgSize) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SMsgSendInfo *pMsgSendInfo = NULL;
|
SMsgSendInfo *pMsgSendInfo = NULL;
|
||||||
CTG_ERR_JRET(ctgMakeMsgSendInfo(pTask, msgType, &pMsgSendInfo));
|
CTG_ERR_JRET(ctgMakeMsgSendInfo(pJob, pTaskId, batchId, msgType, &pMsgSendInfo));
|
||||||
|
|
||||||
ctgUpdateSendTargetInfo(pMsgSendInfo, msgType, pTask);
|
ctgUpdateSendTargetInfo(pMsgSendInfo, msgType, dbFName, vgId);
|
||||||
|
|
||||||
pMsgSendInfo->requestId = pConn->requestId;
|
pMsgSendInfo->requestId = pConn->requestId;
|
||||||
pMsgSendInfo->requestObjRefId = pConn->requestObjRefId;
|
pMsgSendInfo->requestObjRefId = pConn->requestObjRefId;
|
||||||
|
@ -323,24 +408,178 @@ int32_t ctgAsyncSendMsg(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTask* pTask
|
||||||
|
|
||||||
int64_t transporterId = 0;
|
int64_t transporterId = 0;
|
||||||
code = asyncSendMsgToServer(pConn->pTrans, &pConn->mgmtEps, &transporterId, pMsgSendInfo);
|
code = asyncSendMsgToServer(pConn->pTrans, &pConn->mgmtEps, &transporterId, pMsgSendInfo);
|
||||||
|
pMsgSendInfo = NULL;
|
||||||
if (code) {
|
if (code) {
|
||||||
ctgError("asyncSendMsgToSever failed, error: %s", tstrerror(code));
|
ctgError("asyncSendMsgToSever failed, error: %s", tstrerror(code));
|
||||||
CTG_ERR_JRET(code);
|
CTG_ERR_JRET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctgDebug("ctg req msg sent, reqId:0x%" PRIx64 ", msg type:%d, %s", pTask->pJob->queryId, msgType, TMSG_INFO(msgType));
|
ctgDebug("ctg req msg sent, reqId:0x%" PRIx64 ", msg type:%d, %s", pJob->queryId, msgType, TMSG_INFO(msgType));
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
if (pMsgSendInfo) {
|
if (pMsgSendInfo) {
|
||||||
taosMemoryFreeClear(pMsgSendInfo->param);
|
destroySendMsgInfo(pMsgSendInfo);
|
||||||
taosMemoryFreeClear(pMsgSendInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo *pConn, SCtgTask* pTask, int32_t msgType, void *msg, uint32_t msgSize) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SHashObj* pBatchs = pTask->pBatchs;
|
||||||
|
SCtgJob* pJob = pTask->pJob;
|
||||||
|
SCtgBatch* pBatch = taosHashGet(pBatchs, &vgId, sizeof(vgId));
|
||||||
|
int32_t taskNum = taosArrayGetSize(pTask->pJob->pTasks);
|
||||||
|
SCtgBatch newBatch = {0};
|
||||||
|
SBatchMsg req = {0};
|
||||||
|
|
||||||
|
if (NULL == pBatch) {
|
||||||
|
newBatch.pMsgs = taosArrayInit(taskNum, sizeof(SBatchMsg));
|
||||||
|
newBatch.pTaskIds = taosArrayInit(taskNum, sizeof(int32_t));
|
||||||
|
if (NULL == newBatch.pMsgs || NULL == newBatch.pTaskIds) {
|
||||||
|
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
newBatch.conn = *pConn;
|
||||||
|
|
||||||
|
req.msgType = msgType;
|
||||||
|
req.msgLen = msgSize;
|
||||||
|
req.msg = msg;
|
||||||
|
if (NULL == taosArrayPush(newBatch.pMsgs, &req)) {
|
||||||
|
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
if (NULL == taosArrayPush(newBatch.pTaskIds, &pTask->taskId)) {
|
||||||
|
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
newBatch.msgSize = sizeof(SBatchReq) + sizeof(req) + msgSize - POINTER_BYTES;
|
||||||
|
|
||||||
|
if (vgId > 0) {
|
||||||
|
if (TDMT_VND_TABLE_CFG == msgType) {
|
||||||
|
SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx;
|
||||||
|
tNameGetFullDbName(ctx->pName, newBatch.dbFName);
|
||||||
|
} else if (TDMT_VND_TABLE_META == msgType) {
|
||||||
|
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||||
|
tNameGetFullDbName(ctx->pName, newBatch.dbFName);
|
||||||
|
} else {
|
||||||
|
ctgError("invalid vnode msgType %d", msgType);
|
||||||
|
CTG_ERR_JRET(TSDB_CODE_APP_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newBatch.msgType = (vgId > 0) ? TDMT_VND_BATCH_META : TDMT_MND_BATCH_META;
|
||||||
|
newBatch.batchId = atomic_add_fetch_32(&pJob->batchId, 1);
|
||||||
|
|
||||||
|
if (0 != taosHashPut(pBatchs, &vgId, sizeof(vgId), &newBatch, sizeof(newBatch))) {
|
||||||
|
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
ctgDebug("task %d %s req added to batch %d, target vgId %d", pTask->taskId, TMSG_INFO(msgType), newBatch.batchId, vgId);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
req.msgType = msgType;
|
||||||
|
req.msgLen = msgSize;
|
||||||
|
req.msg = msg;
|
||||||
|
if (NULL == taosArrayPush(pBatch->pMsgs, &req)) {
|
||||||
|
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
if (NULL == taosArrayPush(pBatch->pTaskIds, &pTask->taskId)) {
|
||||||
|
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
pBatch->msgSize += sizeof(req) + msgSize - POINTER_BYTES;
|
||||||
|
|
||||||
|
if (vgId > 0) {
|
||||||
|
if (TDMT_VND_TABLE_CFG == msgType) {
|
||||||
|
SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx;
|
||||||
|
tNameGetFullDbName(ctx->pName, newBatch.dbFName);
|
||||||
|
} else if (TDMT_VND_TABLE_META == msgType) {
|
||||||
|
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||||
|
tNameGetFullDbName(ctx->pName, newBatch.dbFName);
|
||||||
|
} else {
|
||||||
|
ctgError("invalid vnode msgType %d", msgType);
|
||||||
|
CTG_ERR_JRET(TSDB_CODE_APP_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ctgDebug("task %d %s req added to batch %d, target vgId %d", pTask->taskId, TMSG_INFO(msgType), pBatch->batchId, vgId);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
ctgFreeBatch(&newBatch);
|
||||||
|
taosMemoryFree(msg);
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgBuildBatchReqMsg(SCtgBatch* pBatch, int32_t vgId, void** msg) {
|
||||||
|
*msg = taosMemoryMalloc(pBatch->msgSize);
|
||||||
|
if (NULL == (*msg)) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t offset = 0;
|
||||||
|
int32_t num = taosArrayGetSize(pBatch->pMsgs);
|
||||||
|
SBatchReq *pBatchReq = (SBatchReq*)(*msg);
|
||||||
|
|
||||||
|
pBatchReq->header.vgId = htonl(vgId);
|
||||||
|
pBatchReq->msgNum = htonl(num);
|
||||||
|
offset += sizeof(SBatchReq);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
|
SBatchMsg* pReq = taosArrayGet(pBatch->pMsgs, i);
|
||||||
|
*(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgType);
|
||||||
|
offset += sizeof(pReq->msgType);
|
||||||
|
*(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgLen);
|
||||||
|
offset += sizeof(pReq->msgLen);
|
||||||
|
memcpy((char*)(*msg) + offset, pReq->msg, pReq->msgLen);
|
||||||
|
offset += pReq->msgLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(pBatch->msgSize == offset);
|
||||||
|
|
||||||
|
qDebug("batch req %d to vg %d msg built with %d meta reqs", pBatch->batchId, vgId, num);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ctgLaunchBatchs(SCatalog* pCtg, SCtgJob *pJob, SHashObj* pBatchs) {
|
||||||
|
int32_t code = 0;
|
||||||
|
void* msg = NULL;
|
||||||
|
void* p = taosHashIterate(pBatchs, NULL);
|
||||||
|
while (NULL != p) {
|
||||||
|
size_t len = 0;
|
||||||
|
int32_t* vgId = taosHashGetKey(p, &len);
|
||||||
|
SCtgBatch* pBatch = (SCtgBatch*)p;
|
||||||
|
|
||||||
|
ctgDebug("QID:0x%" PRIx64 " ctg start to launch batch %d", pJob->queryId, pBatch->batchId);
|
||||||
|
|
||||||
|
CTG_ERR_JRET(ctgBuildBatchReqMsg(pBatch, *vgId, &msg));
|
||||||
|
code = ctgAsyncSendMsg(pCtg, &pBatch->conn, pJob, pBatch->pTaskIds, pBatch->batchId,
|
||||||
|
pBatch->dbFName, *vgId, pBatch->msgType, msg, pBatch->msgSize);
|
||||||
|
pBatch->pTaskIds = NULL;
|
||||||
|
CTG_ERR_JRET(code);
|
||||||
|
|
||||||
|
p = taosHashIterate(pBatchs, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
if (p) {
|
||||||
|
taosHashCancelIterate(pBatchs, p);
|
||||||
|
}
|
||||||
|
taosMemoryFree(msg);
|
||||||
|
|
||||||
|
CTG_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray *out, SCtgTask* pTask) {
|
int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray *out, SCtgTask* pTask) {
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
int32_t msgLen = 0;
|
int32_t msgLen = 0;
|
||||||
|
@ -361,7 +600,18 @@ int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray
|
||||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, NULL));
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, NULL));
|
||||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
|
||||||
|
#if CTG_BATCH_FETCH
|
||||||
|
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||||
|
#else
|
||||||
|
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
if (NULL == pTaskId) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
taosArrayPush(pTaskId, &pTask->taskId);
|
||||||
|
|
||||||
|
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
|
@ -396,7 +646,18 @@ int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray
|
||||||
|
|
||||||
if (pTask) {
|
if (pTask) {
|
||||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, NULL));
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, NULL));
|
||||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
|
||||||
|
#if CTG_BATCH_FETCH
|
||||||
|
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||||
|
#else
|
||||||
|
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
if (NULL == pTaskId) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
taosArrayPush(pTaskId, &pTask->taskId);
|
||||||
|
|
||||||
|
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
|
@ -436,8 +697,18 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SBuildU
|
||||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, input->db));
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, input->db));
|
||||||
|
|
||||||
|
#if CTG_BATCH_FETCH
|
||||||
|
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||||
|
#else
|
||||||
|
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
if (NULL == pTaskId) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
taosArrayPush(pTaskId, &pTask->taskId);
|
||||||
|
|
||||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
|
@ -476,8 +747,18 @@ int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char
|
||||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)dbFName));
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)dbFName));
|
||||||
|
|
||||||
|
#if CTG_BATCH_FETCH
|
||||||
|
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||||
|
#else
|
||||||
|
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
if (NULL == pTaskId) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
taosArrayPush(pTaskId, &pTask->taskId);
|
||||||
|
|
||||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
|
@ -516,8 +797,18 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const
|
||||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)indexName));
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)indexName));
|
||||||
|
|
||||||
|
#if CTG_BATCH_FETCH
|
||||||
|
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||||
|
#else
|
||||||
|
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
if (NULL == pTaskId) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
taosArrayPush(pTaskId, &pTask->taskId);
|
||||||
|
|
||||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
|
@ -559,8 +850,18 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *n
|
||||||
}
|
}
|
||||||
|
|
||||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)tbFName));
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)tbFName));
|
||||||
|
|
||||||
|
#if CTG_BATCH_FETCH
|
||||||
|
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||||
|
#else
|
||||||
|
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
if (NULL == pTaskId) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
taosArrayPush(pTaskId, &pTask->taskId);
|
||||||
|
|
||||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
|
@ -599,8 +900,18 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const ch
|
||||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)funcName));
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)funcName));
|
||||||
|
|
||||||
|
#if CTG_BATCH_FETCH
|
||||||
|
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||||
|
#else
|
||||||
|
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
if (NULL == pTaskId) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
taosArrayPush(pTaskId, &pTask->taskId);
|
||||||
|
|
||||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
|
@ -639,8 +950,18 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const
|
||||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)user));
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)user));
|
||||||
|
|
||||||
|
#if CTG_BATCH_FETCH
|
||||||
|
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||||
|
#else
|
||||||
|
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
if (NULL == pTaskId) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
taosArrayPush(pTaskId, &pTask->taskId);
|
||||||
|
|
||||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
|
@ -684,8 +1005,17 @@ int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo *pConn, char
|
||||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, tbFName));
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, tbFName));
|
||||||
|
#if CTG_BATCH_FETCH
|
||||||
|
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||||
|
#else
|
||||||
|
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
if (NULL == pTaskId) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
taosArrayPush(pTaskId, &pTask->taskId);
|
||||||
|
|
||||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
|
@ -744,7 +1074,21 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SNa
|
||||||
.requestId = pConn->requestId,
|
.requestId = pConn->requestId,
|
||||||
.requestObjRefId = pConn->requestObjRefId,
|
.requestObjRefId = pConn->requestObjRefId,
|
||||||
.mgmtEps = vgroupInfo->epSet};
|
.mgmtEps = vgroupInfo->epSet};
|
||||||
CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask, reqType, msg, msgLen));
|
|
||||||
|
#if CTG_BATCH_FETCH
|
||||||
|
CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, pTask, reqType, msg, msgLen));
|
||||||
|
#else
|
||||||
|
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
tNameGetFullDbName(ctx->pName, dbFName);
|
||||||
|
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
if (NULL == pTaskId) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
taosArrayPush(pTaskId, &pTask->taskId);
|
||||||
|
|
||||||
|
CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, dbFName, ctx->vgId, reqType, msg, msgLen));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
|
@ -791,7 +1135,20 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const S
|
||||||
.requestId = pConn->requestId,
|
.requestId = pConn->requestId,
|
||||||
.requestObjRefId = pConn->requestObjRefId,
|
.requestObjRefId = pConn->requestObjRefId,
|
||||||
.mgmtEps = vgroupInfo->epSet};
|
.mgmtEps = vgroupInfo->epSet};
|
||||||
CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask, reqType, msg, msgLen));
|
#if CTG_BATCH_FETCH
|
||||||
|
CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, pTask, reqType, msg, msgLen));
|
||||||
|
#else
|
||||||
|
SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx;
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
tNameGetFullDbName(ctx->pName, dbFName);
|
||||||
|
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
if (NULL == pTaskId) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
taosArrayPush(pTaskId, &pTask->taskId);
|
||||||
|
|
||||||
|
CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, dbFName, ctx->pVgInfo->vgId, reqType, msg, msgLen));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
|
@ -832,8 +1189,17 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const S
|
||||||
|
|
||||||
if (pTask) {
|
if (pTask) {
|
||||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, (char*)tbFName));
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, (char*)tbFName));
|
||||||
|
#if CTG_BATCH_FETCH
|
||||||
|
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||||
|
#else
|
||||||
|
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
if (NULL == pTaskId) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
taosArrayPush(pTaskId, &pTask->taskId);
|
||||||
|
|
||||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
|
@ -868,8 +1234,18 @@ int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, char **ou
|
||||||
|
|
||||||
if (pTask) {
|
if (pTask) {
|
||||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, NULL));
|
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, NULL));
|
||||||
|
|
||||||
|
#if CTG_BATCH_FETCH
|
||||||
|
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||||
|
#else
|
||||||
|
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||||
|
if (NULL == pTaskId) {
|
||||||
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
taosArrayPush(pTaskId, &pTask->taskId);
|
||||||
|
|
||||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
|
|
|
@ -19,6 +19,39 @@
|
||||||
#include "catalogInt.h"
|
#include "catalogInt.h"
|
||||||
#include "systable.h"
|
#include "systable.h"
|
||||||
|
|
||||||
|
void ctgFreeMsgSendParam(void* param) {
|
||||||
|
if (NULL == param) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCtgTaskCallbackParam* pParam = (SCtgTaskCallbackParam*)param;
|
||||||
|
taosArrayDestroy(pParam->taskId);
|
||||||
|
|
||||||
|
taosMemoryFree(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ctgFreeBatch(SCtgBatch *pBatch) {
|
||||||
|
if (NULL == pBatch) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pBatch->pMsgs);
|
||||||
|
taosArrayDestroy(pBatch->pTaskIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ctgFreeBatchs(SHashObj *pBatchs) {
|
||||||
|
void* p = taosHashIterate(pBatchs, NULL);
|
||||||
|
while (NULL != p) {
|
||||||
|
SCtgBatch* pBatch = (SCtgBatch*)p;
|
||||||
|
|
||||||
|
ctgFreeBatch(pBatch);
|
||||||
|
|
||||||
|
p = taosHashIterate(pBatchs, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosHashCleanup(pBatchs);
|
||||||
|
}
|
||||||
|
|
||||||
char *ctgTaskTypeStr(CTG_TASK_TYPE type) {
|
char *ctgTaskTypeStr(CTG_TASK_TYPE type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CTG_TASK_GET_QNODE:
|
case CTG_TASK_GET_QNODE:
|
||||||
|
@ -612,6 +645,7 @@ void ctgFreeJob(void* job) {
|
||||||
uint64_t qid = pJob->queryId;
|
uint64_t qid = pJob->queryId;
|
||||||
|
|
||||||
ctgFreeTasks(pJob->pTasks);
|
ctgFreeTasks(pJob->pTasks);
|
||||||
|
ctgFreeBatchs(pJob->pBatchs);
|
||||||
|
|
||||||
ctgFreeSMetaData(&pJob->jobRes);
|
ctgFreeSMetaData(&pJob->jobRes);
|
||||||
|
|
||||||
|
@ -867,14 +901,10 @@ int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, SCtgTask* pTask) {
|
int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, char* dbFName, int32_t vgId) {
|
||||||
if (msgType == TDMT_VND_TABLE_META) {
|
if (msgType == TDMT_VND_TABLE_META || msgType == TDMT_VND_TABLE_CFG || msgType == TDMT_VND_BATCH_META) {
|
||||||
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
|
||||||
char dbFName[TSDB_DB_FNAME_LEN];
|
|
||||||
tNameGetFullDbName(ctx->pName, dbFName);
|
|
||||||
|
|
||||||
pMsgSendInfo->target.type = TARGET_TYPE_VNODE;
|
pMsgSendInfo->target.type = TARGET_TYPE_VNODE;
|
||||||
pMsgSendInfo->target.vgId = ctx->vgId;
|
pMsgSendInfo->target.vgId = vgId;
|
||||||
pMsgSendInfo->target.dbFName = strdup(dbFName);
|
pMsgSendInfo->target.dbFName = strdup(dbFName);
|
||||||
} else {
|
} else {
|
||||||
pMsgSendInfo->target.type = TARGET_TYPE_MNODE;
|
pMsgSendInfo->target.type = TARGET_TYPE_MNODE;
|
||||||
|
|
|
@ -90,7 +90,8 @@ static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInp
|
||||||
pRes->uidList = pHandle->pParam->pUidList;
|
pRes->uidList = pHandle->pParam->pUidList;
|
||||||
pRes->skey = pHandle->pDeleter->deleteTimeRange.skey;
|
pRes->skey = pHandle->pDeleter->deleteTimeRange.skey;
|
||||||
pRes->ekey = pHandle->pDeleter->deleteTimeRange.ekey;
|
pRes->ekey = pHandle->pDeleter->deleteTimeRange.ekey;
|
||||||
strcpy(pRes->tableFName, pHandle->pDeleter->tableFName);
|
strcpy(pRes->tableName, pHandle->pDeleter->tableFName);
|
||||||
|
strcpy(pRes->tsColName, pHandle->pDeleter->tsColName);
|
||||||
pRes->affectedRows = *(int64_t*)pColRes->pData;
|
pRes->affectedRows = *(int64_t*)pColRes->pData;
|
||||||
|
|
||||||
pBuf->useSize += pEntry->dataLen;
|
pBuf->useSize += pEntry->dataLen;
|
||||||
|
|
|
@ -30,8 +30,7 @@ static void cleanupRefPool() {
|
||||||
taosCloseRef(ref);
|
taosCloseRef(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t numOfBlocks, int32_t type, bool assignUid,
|
static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t numOfBlocks, int32_t type, char* id) {
|
||||||
char* id) {
|
|
||||||
ASSERT(pOperator != NULL);
|
ASSERT(pOperator != NULL);
|
||||||
if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
||||||
if (pOperator->numOfDownstream == 0) {
|
if (pOperator->numOfDownstream == 0) {
|
||||||
|
@ -44,12 +43,12 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
}
|
}
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
return doSetStreamBlock(pOperator->pDownstream[0], input, numOfBlocks, type, assignUid, id);
|
return doSetStreamBlock(pOperator->pDownstream[0], input, numOfBlocks, type, id);
|
||||||
} else {
|
} else {
|
||||||
pOperator->status = OP_NOT_OPENED;
|
pOperator->status = OP_NOT_OPENED;
|
||||||
|
|
||||||
SStreamScanInfo* pInfo = pOperator->info;
|
SStreamScanInfo* pInfo = pOperator->info;
|
||||||
pInfo->assignBlockUid = assignUid;
|
/*pInfo->assignBlockUid = assignUid;*/
|
||||||
|
|
||||||
// TODO: if a block was set but not consumed,
|
// TODO: if a block was set but not consumed,
|
||||||
// prevent setting a different type of block
|
// prevent setting a different type of block
|
||||||
|
@ -95,11 +94,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qSetStreamInput(qTaskInfo_t tinfo, const void* input, int32_t type, bool assignUid) {
|
int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type) {
|
||||||
return qSetMultiStreamInput(tinfo, input, 1, type, assignUid);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type, bool assignUid) {
|
|
||||||
if (tinfo == NULL) {
|
if (tinfo == NULL) {
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -110,8 +105,7 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO
|
||||||
|
|
||||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||||
|
|
||||||
int32_t code =
|
int32_t code = doSetStreamBlock(pTaskInfo->pRoot, (void**)pBlocks, numOfBlocks, type, GET_TASKID(pTaskInfo));
|
||||||
doSetStreamBlock(pTaskInfo->pRoot, (void**)pBlocks, numOfBlocks, type, assignUid, GET_TASKID(pTaskInfo));
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("%s failed to set the stream block data", GET_TASKID(pTaskInfo));
|
qError("%s failed to set the stream block data", GET_TASKID(pTaskInfo));
|
||||||
} else {
|
} else {
|
||||||
|
@ -337,7 +331,7 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
|
||||||
}
|
}
|
||||||
|
|
||||||
code = dsCreateDataSinker(pSubplan->pDataSink, handle, pSinkParam);
|
code = dsCreateDataSinker(pSubplan->pDataSink, handle, pSinkParam);
|
||||||
if(code != TSDB_CODE_SUCCESS){
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
taosMemoryFreeClear(pSinkParam);
|
taosMemoryFreeClear(pSinkParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -401,7 +401,8 @@ static int32_t logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModi
|
||||||
COPY_SCALAR_FIELD(tableId);
|
COPY_SCALAR_FIELD(tableId);
|
||||||
COPY_SCALAR_FIELD(stableId);
|
COPY_SCALAR_FIELD(stableId);
|
||||||
COPY_SCALAR_FIELD(tableType);
|
COPY_SCALAR_FIELD(tableType);
|
||||||
COPY_CHAR_ARRAY_FIELD(tableFName);
|
COPY_CHAR_ARRAY_FIELD(tableName);
|
||||||
|
COPY_CHAR_ARRAY_FIELD(tsColName);
|
||||||
COPY_OBJECT_FIELD(deleteTimeRange, sizeof(STimeWindow));
|
COPY_OBJECT_FIELD(deleteTimeRange, sizeof(STimeWindow));
|
||||||
CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone);
|
CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone);
|
||||||
CLONE_NODE_LIST_FIELD(pInsertCols);
|
CLONE_NODE_LIST_FIELD(pInsertCols);
|
||||||
|
|
|
@ -2332,7 +2332,7 @@ static int32_t physiQueryInsertNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkQueryInsertPhysiPlanTableType, pNode->tableType);
|
code = tjsonAddIntegerToObject(pJson, jkQueryInsertPhysiPlanTableType, pNode->tableType);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddStringToObject(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableFName);
|
code = tjsonAddStringToObject(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableName);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkQueryInsertPhysiPlanVgId, pNode->vgId);
|
code = tjsonAddIntegerToObject(pJson, jkQueryInsertPhysiPlanVgId, pNode->vgId);
|
||||||
|
@ -2361,7 +2361,7 @@ static int32_t jsonToPhysiQueryInsertNode(const SJson* pJson, void* pObj) {
|
||||||
code = tjsonGetTinyIntValue(pJson, jkQueryInsertPhysiPlanTableType, &pNode->tableType);
|
code = tjsonGetTinyIntValue(pJson, jkQueryInsertPhysiPlanTableType, &pNode->tableType);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetStringValue(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableFName);
|
code = tjsonGetStringValue(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableName);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetIntValue(pJson, jkQueryInsertPhysiPlanVgId, &pNode->vgId);
|
code = tjsonGetIntValue(pJson, jkQueryInsertPhysiPlanVgId, &pNode->vgId);
|
||||||
|
@ -2376,6 +2376,7 @@ static int32_t jsonToPhysiQueryInsertNode(const SJson* pJson, void* pObj) {
|
||||||
static const char* jkDeletePhysiPlanTableId = "TableId";
|
static const char* jkDeletePhysiPlanTableId = "TableId";
|
||||||
static const char* jkDeletePhysiPlanTableType = "TableType";
|
static const char* jkDeletePhysiPlanTableType = "TableType";
|
||||||
static const char* jkDeletePhysiPlanTableFName = "TableFName";
|
static const char* jkDeletePhysiPlanTableFName = "TableFName";
|
||||||
|
static const char* jkDeletePhysiPlanTsColName = "TsColName";
|
||||||
static const char* jkDeletePhysiPlanDeleteTimeRangeStartKey = "DeleteTimeRangeStartKey";
|
static const char* jkDeletePhysiPlanDeleteTimeRangeStartKey = "DeleteTimeRangeStartKey";
|
||||||
static const char* jkDeletePhysiPlanDeleteTimeRangeEndKey = "DeleteTimeRangeEndKey";
|
static const char* jkDeletePhysiPlanDeleteTimeRangeEndKey = "DeleteTimeRangeEndKey";
|
||||||
static const char* jkDeletePhysiPlanAffectedRows = "AffectedRows";
|
static const char* jkDeletePhysiPlanAffectedRows = "AffectedRows";
|
||||||
|
@ -2393,6 +2394,9 @@ static int32_t physiDeleteNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddStringToObject(pJson, jkDeletePhysiPlanTableFName, pNode->tableFName);
|
code = tjsonAddStringToObject(pJson, jkDeletePhysiPlanTableFName, pNode->tableFName);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonAddStringToObject(pJson, jkDeletePhysiPlanTsColName, pNode->tsColName);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddIntegerToObject(pJson, jkDeletePhysiPlanDeleteTimeRangeStartKey, pNode->deleteTimeRange.skey);
|
code = tjsonAddIntegerToObject(pJson, jkDeletePhysiPlanDeleteTimeRangeStartKey, pNode->deleteTimeRange.skey);
|
||||||
}
|
}
|
||||||
|
@ -2419,6 +2423,9 @@ static int32_t jsonToPhysiDeleteNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetStringValue(pJson, jkDeletePhysiPlanTableFName, pNode->tableFName);
|
code = tjsonGetStringValue(pJson, jkDeletePhysiPlanTableFName, pNode->tableFName);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = tjsonGetStringValue(pJson, jkDeletePhysiPlanTsColName, pNode->tsColName);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetBigIntValue(pJson, jkDeletePhysiPlanDeleteTimeRangeStartKey, &pNode->deleteTimeRange.skey);
|
code = tjsonGetBigIntValue(pJson, jkDeletePhysiPlanDeleteTimeRangeStartKey, &pNode->deleteTimeRange.skey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1292,8 +1292,8 @@ static int32_t createVnodeModifLogicNodeByDelete(SLogicPlanContext* pCxt, SDelet
|
||||||
pModify->modifyType = MODIFY_TABLE_TYPE_DELETE;
|
pModify->modifyType = MODIFY_TABLE_TYPE_DELETE;
|
||||||
pModify->tableId = pRealTable->pMeta->uid;
|
pModify->tableId = pRealTable->pMeta->uid;
|
||||||
pModify->tableType = pRealTable->pMeta->tableType;
|
pModify->tableType = pRealTable->pMeta->tableType;
|
||||||
snprintf(pModify->tableFName, sizeof(pModify->tableFName), "%d.%s.%s", pCxt->pPlanCxt->acctId,
|
snprintf(pModify->tableName, sizeof(pModify->tableName), "%s", pRealTable->table.tableName);
|
||||||
pRealTable->table.dbName, pRealTable->table.tableName);
|
strcpy(pModify->tsColName, pRealTable->pMeta->schema->name);
|
||||||
pModify->deleteTimeRange = pDelete->timeRange;
|
pModify->deleteTimeRange = pDelete->timeRange;
|
||||||
pModify->pAffectedRows = nodesCloneNode(pDelete->pCountFunc);
|
pModify->pAffectedRows = nodesCloneNode(pDelete->pCountFunc);
|
||||||
if (NULL == pModify->pAffectedRows) {
|
if (NULL == pModify->pAffectedRows) {
|
||||||
|
@ -1342,8 +1342,7 @@ static int32_t createVnodeModifLogicNodeByInsert(SLogicPlanContext* pCxt, SInser
|
||||||
pModify->tableId = pRealTable->pMeta->uid;
|
pModify->tableId = pRealTable->pMeta->uid;
|
||||||
pModify->stableId = pRealTable->pMeta->suid;
|
pModify->stableId = pRealTable->pMeta->suid;
|
||||||
pModify->tableType = pRealTable->pMeta->tableType;
|
pModify->tableType = pRealTable->pMeta->tableType;
|
||||||
snprintf(pModify->tableFName, sizeof(pModify->tableFName), "%d.%s.%s", pCxt->pPlanCxt->acctId,
|
snprintf(pModify->tableName, sizeof(pModify->tableName), "%s", pRealTable->table.tableName);
|
||||||
pRealTable->table.dbName, pRealTable->table.tableName);
|
|
||||||
TSWAP(pModify->pVgroupList, pRealTable->pVgroupList);
|
TSWAP(pModify->pVgroupList, pRealTable->pVgroupList);
|
||||||
pModify->pInsertCols = nodesCloneList(pInsert->pCols);
|
pModify->pInsertCols = nodesCloneList(pInsert->pCols);
|
||||||
if (NULL == pModify->pInsertCols) {
|
if (NULL == pModify->pInsertCols) {
|
||||||
|
|
|
@ -1588,7 +1588,7 @@ static int32_t createQueryInserter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNod
|
||||||
pInserter->tableId = pModify->tableId;
|
pInserter->tableId = pModify->tableId;
|
||||||
pInserter->stableId = pModify->stableId;
|
pInserter->stableId = pModify->stableId;
|
||||||
pInserter->tableType = pModify->tableType;
|
pInserter->tableType = pModify->tableType;
|
||||||
strcpy(pInserter->tableFName, pModify->tableFName);
|
strcpy(pInserter->tableName, pModify->tableName);
|
||||||
pInserter->vgId = pModify->pVgroupList->vgroups[0].vgId;
|
pInserter->vgId = pModify->pVgroupList->vgroups[0].vgId;
|
||||||
pInserter->epSet = pModify->pVgroupList->vgroups[0].epSet;
|
pInserter->epSet = pModify->pVgroupList->vgroups[0].epSet;
|
||||||
vgroupInfoToNodeAddr(pModify->pVgroupList->vgroups, &pSubplan->execNode);
|
vgroupInfoToNodeAddr(pModify->pVgroupList->vgroups, &pSubplan->execNode);
|
||||||
|
@ -1638,7 +1638,8 @@ static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode*
|
||||||
|
|
||||||
pDeleter->tableId = pModify->tableId;
|
pDeleter->tableId = pModify->tableId;
|
||||||
pDeleter->tableType = pModify->tableType;
|
pDeleter->tableType = pModify->tableType;
|
||||||
strcpy(pDeleter->tableFName, pModify->tableFName);
|
strcpy(pDeleter->tableFName, pModify->tableName);
|
||||||
|
strcpy(pDeleter->tsColName, pModify->tsColName);
|
||||||
pDeleter->deleteTimeRange = pModify->deleteTimeRange;
|
pDeleter->deleteTimeRange = pModify->deleteTimeRange;
|
||||||
|
|
||||||
int32_t code = setNodeSlotId(pCxt, pRoot->pOutputDataBlockDesc->dataBlockId, -1, pModify->pAffectedRows,
|
int32_t code = setNodeSlotId(pCxt, pRoot->pOutputDataBlockDesc->dataBlockId, -1, pModify->pAffectedRows,
|
||||||
|
|
|
@ -283,7 +283,8 @@ int32_t qwGetDeleteResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, SDeleteRes *pRes
|
||||||
pRes->skey = pDelRes->skey;
|
pRes->skey = pDelRes->skey;
|
||||||
pRes->ekey = pDelRes->ekey;
|
pRes->ekey = pDelRes->ekey;
|
||||||
pRes->affectedRows = pDelRes->affectedRows;
|
pRes->affectedRows = pDelRes->affectedRows;
|
||||||
strcpy(pRes->tableFName, pDelRes->tableFName);
|
strcpy(pRes->tableFName, pDelRes->tableName);
|
||||||
|
strcpy(pRes->tsColName, pDelRes->tsColName);
|
||||||
taosMemoryFree(output.pData);
|
taosMemoryFree(output.pData);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -227,6 +227,8 @@ int32_t streamDispatchOneReq(SStreamTask* pTask, const SStreamDispatchReq* pReq,
|
||||||
msg.pCont = buf;
|
msg.pCont = buf;
|
||||||
msg.msgType = pTask->dispatchMsgType;
|
msg.msgType = pTask->dispatchMsgType;
|
||||||
|
|
||||||
|
qDebug("dispatch from task %d to task %d node %d", pTask->taskId, pReq->taskId, vgId);
|
||||||
|
|
||||||
tmsgSendReq(pEpSet, &msg);
|
tmsgSendReq(pEpSet, &msg);
|
||||||
|
|
||||||
code = 0;
|
code = 0;
|
||||||
|
@ -281,8 +283,10 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
} else if (pTask->dispatchType == TASK_DISPATCH__SHUFFLE) {
|
} else if (pTask->dispatchType == TASK_DISPATCH__SHUFFLE) {
|
||||||
SArray* vgInfo = pTask->shuffleDispatcher.dbInfo.pVgroupInfos;
|
int32_t rspCnt = atomic_load_32(&pTask->shuffleDispatcher.waitingRspCnt);
|
||||||
ASSERT(pTask->shuffleDispatcher.waitingRspCnt == 0);
|
ASSERT(rspCnt == 0);
|
||||||
|
|
||||||
|
SArray* vgInfo = pTask->shuffleDispatcher.dbInfo.pVgroupInfos;
|
||||||
int32_t vgSz = taosArrayGetSize(vgInfo);
|
int32_t vgSz = taosArrayGetSize(vgInfo);
|
||||||
SStreamDispatchReq* pReqs = taosMemoryCalloc(vgSz, sizeof(SStreamDispatchReq));
|
SStreamDispatchReq* pReqs = taosMemoryCalloc(vgSz, sizeof(SStreamDispatchReq));
|
||||||
if (pReqs == NULL) {
|
if (pReqs == NULL) {
|
||||||
|
@ -301,7 +305,10 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat
|
||||||
if (pReqs[i].data == NULL || pReqs[i].dataLen == NULL) {
|
if (pReqs[i].data == NULL || pReqs[i].dataLen == NULL) {
|
||||||
goto FAIL_SHUFFLE_DISPATCH;
|
goto FAIL_SHUFFLE_DISPATCH;
|
||||||
}
|
}
|
||||||
|
SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, i);
|
||||||
|
pReqs[i].taskId = pVgInfo->taskId;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < blockNum; i++) {
|
for (int32_t i = 0; i < blockNum; i++) {
|
||||||
SSDataBlock* pDataBlock = taosArrayGet(pData->blocks, i);
|
SSDataBlock* pDataBlock = taosArrayGet(pData->blocks, i);
|
||||||
char* ctbName = buildCtbNameByGroupId(pTask->shuffleDispatcher.stbFullName, pDataBlock->info.groupId);
|
char* ctbName = buildCtbNameByGroupId(pTask->shuffleDispatcher.stbFullName, pDataBlock->info.groupId);
|
||||||
|
@ -309,6 +316,9 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat
|
||||||
// TODO: get hash function by hashMethod
|
// TODO: get hash function by hashMethod
|
||||||
uint32_t hashValue = MurmurHash3_32(ctbName, strlen(ctbName));
|
uint32_t hashValue = MurmurHash3_32(ctbName, strlen(ctbName));
|
||||||
|
|
||||||
|
taosMemoryFree(ctbName);
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
// TODO: optimize search
|
// TODO: optimize search
|
||||||
int32_t j;
|
int32_t j;
|
||||||
for (j = 0; j < vgSz; j++) {
|
for (j = 0; j < vgSz; j++) {
|
||||||
|
@ -318,12 +328,17 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat
|
||||||
if (streamAddBlockToDispatchMsg(pDataBlock, &pReqs[j]) < 0) {
|
if (streamAddBlockToDispatchMsg(pDataBlock, &pReqs[j]) < 0) {
|
||||||
goto FAIL_SHUFFLE_DISPATCH;
|
goto FAIL_SHUFFLE_DISPATCH;
|
||||||
}
|
}
|
||||||
pReqs[j].taskId = pVgInfo->taskId;
|
if (pReqs[j].blockNum == 0) {
|
||||||
|
atomic_add_fetch_32(&pTask->shuffleDispatcher.waitingRspCnt, 1);
|
||||||
|
}
|
||||||
pReqs[j].blockNum++;
|
pReqs[j].blockNum++;
|
||||||
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ASSERT(found);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < vgSz; i++) {
|
for (int32_t i = 0; i < vgSz; i++) {
|
||||||
if (pReqs[i].blockNum > 0) {
|
if (pReqs[i].blockNum > 0) {
|
||||||
// send
|
// send
|
||||||
|
@ -331,7 +346,6 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat
|
||||||
if (streamDispatchOneReq(pTask, &pReqs[i], pVgInfo->vgId, &pVgInfo->epSet) < 0) {
|
if (streamDispatchOneReq(pTask, &pReqs[i], pVgInfo->vgId, &pVgInfo->epSet) < 0) {
|
||||||
goto FAIL_SHUFFLE_DISPATCH;
|
goto FAIL_SHUFFLE_DISPATCH;
|
||||||
}
|
}
|
||||||
pTask->shuffleDispatcher.waitingRspCnt++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
|
@ -22,22 +22,22 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes)
|
||||||
SStreamQueueItem* pItem = (SStreamQueueItem*)data;
|
SStreamQueueItem* pItem = (SStreamQueueItem*)data;
|
||||||
if (pItem->type == STREAM_INPUT__GET_RES) {
|
if (pItem->type == STREAM_INPUT__GET_RES) {
|
||||||
SStreamTrigger* pTrigger = (SStreamTrigger*)data;
|
SStreamTrigger* pTrigger = (SStreamTrigger*)data;
|
||||||
qSetMultiStreamInput(exec, pTrigger->pBlock, 1, STREAM_INPUT__DATA_BLOCK, false);
|
qSetMultiStreamInput(exec, pTrigger->pBlock, 1, STREAM_INPUT__DATA_BLOCK);
|
||||||
} else if (pItem->type == STREAM_INPUT__DATA_SUBMIT) {
|
} else if (pItem->type == STREAM_INPUT__DATA_SUBMIT) {
|
||||||
ASSERT(pTask->isDataScan);
|
ASSERT(pTask->isDataScan);
|
||||||
SStreamDataSubmit* pSubmit = (SStreamDataSubmit*)data;
|
SStreamDataSubmit* pSubmit = (SStreamDataSubmit*)data;
|
||||||
qDebug("task %d %p set submit input %p %p %d 1", pTask->taskId, pTask, pSubmit, pSubmit->data, *pSubmit->dataRef);
|
qDebug("task %d %p set submit input %p %p %d 1", pTask->taskId, pTask, pSubmit, pSubmit->data, *pSubmit->dataRef);
|
||||||
qSetStreamInput(exec, pSubmit->data, STREAM_INPUT__DATA_SUBMIT, false);
|
qSetMultiStreamInput(exec, pSubmit->data, 1, STREAM_INPUT__DATA_SUBMIT);
|
||||||
} else if (pItem->type == STREAM_INPUT__DATA_BLOCK || pItem->type == STREAM_INPUT__DATA_RETRIEVE) {
|
} else if (pItem->type == STREAM_INPUT__DATA_BLOCK || pItem->type == STREAM_INPUT__DATA_RETRIEVE) {
|
||||||
SStreamDataBlock* pBlock = (SStreamDataBlock*)data;
|
SStreamDataBlock* pBlock = (SStreamDataBlock*)data;
|
||||||
SArray* blocks = pBlock->blocks;
|
SArray* blocks = pBlock->blocks;
|
||||||
qDebug("task %d %p set ssdata input", pTask->taskId, pTask);
|
qDebug("task %d %p set ssdata input", pTask->taskId, pTask);
|
||||||
qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_INPUT__DATA_BLOCK, false);
|
qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_INPUT__DATA_BLOCK);
|
||||||
} else if (pItem->type == STREAM_INPUT__MERGED_SUBMIT) {
|
} else if (pItem->type == STREAM_INPUT__MERGED_SUBMIT) {
|
||||||
SStreamMergedSubmit* pMerged = (SStreamMergedSubmit*)data;
|
SStreamMergedSubmit* pMerged = (SStreamMergedSubmit*)data;
|
||||||
SArray* blocks = pMerged->reqs;
|
SArray* blocks = pMerged->reqs;
|
||||||
qDebug("task %d %p set submit input (merged), batch num: %d", pTask->taskId, pTask, (int32_t)blocks->size);
|
qDebug("task %d %p set submit input (merged), batch num: %d", pTask->taskId, pTask, (int32_t)blocks->size);
|
||||||
qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_INPUT__MERGED_SUBMIT, false);
|
qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_INPUT__MERGED_SUBMIT);
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
|
||||||
if (tEncodeI32(pEncoder, pTask->selfChildId) < 0) return -1;
|
if (tEncodeI32(pEncoder, pTask->selfChildId) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pTask->nodeId) < 0) return -1;
|
if (tEncodeI32(pEncoder, pTask->nodeId) < 0) return -1;
|
||||||
if (tEncodeSEpSet(pEncoder, &pTask->epSet) < 0) return -1;
|
if (tEncodeSEpSet(pEncoder, &pTask->epSet) < 0) return -1;
|
||||||
if (tEncodeI32(pEncoder, pTask->numOfVgroups) < 0) return -1;
|
/*if (tEncodeI32(pEncoder, pTask->numOfVgroups) < 0) return -1;*/
|
||||||
|
|
||||||
int32_t epSz = taosArrayGetSize(pTask->childEpInfo);
|
int32_t epSz = taosArrayGetSize(pTask->childEpInfo);
|
||||||
if (tEncodeI32(pEncoder, epSz) < 0) return -1;
|
if (tEncodeI32(pEncoder, epSz) < 0) return -1;
|
||||||
|
@ -119,7 +119,7 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
||||||
if (tDecodeI32(pDecoder, &pTask->selfChildId) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pTask->selfChildId) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pTask->nodeId) < 0) return -1;
|
if (tDecodeI32(pDecoder, &pTask->nodeId) < 0) return -1;
|
||||||
if (tDecodeSEpSet(pDecoder, &pTask->epSet) < 0) return -1;
|
if (tDecodeSEpSet(pDecoder, &pTask->epSet) < 0) return -1;
|
||||||
if (tDecodeI32(pDecoder, &pTask->numOfVgroups) < 0) return -1;
|
/*if (tDecodeI32(pDecoder, &pTask->numOfVgroups) < 0) return -1;*/
|
||||||
|
|
||||||
int32_t epSz;
|
int32_t epSz;
|
||||||
if (tDecodeI32(pDecoder, &epSz) < 0) return -1;
|
if (tDecodeI32(pDecoder, &epSz) < 0) return -1;
|
||||||
|
|
|
@ -61,26 +61,31 @@ static inline int32_t compareWalFileInfo(const void* pLeft, const void* pRight)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int64_t walGetLastFileSize(SWal* pWal) {
|
static inline int64_t walGetLastFileSize(SWal* pWal) {
|
||||||
|
if (taosArrayGetSize(pWal->fileInfoSet) == 0) return 0;
|
||||||
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGetLast(pWal->fileInfoSet);
|
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGetLast(pWal->fileInfoSet);
|
||||||
return pInfo->fileSize;
|
return pInfo->fileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int64_t walGetLastFileFirstVer(SWal* pWal) {
|
static inline int64_t walGetLastFileFirstVer(SWal* pWal) {
|
||||||
|
if (taosArrayGetSize(pWal->fileInfoSet) == 0) return -1;
|
||||||
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGetLast(pWal->fileInfoSet);
|
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGetLast(pWal->fileInfoSet);
|
||||||
return pInfo->firstVer;
|
return pInfo->firstVer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int64_t walGetCurFileFirstVer(SWal* pWal) {
|
static inline int64_t walGetCurFileFirstVer(SWal* pWal) {
|
||||||
|
if (pWal->writeCur == -1) return -1;
|
||||||
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur);
|
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur);
|
||||||
return pInfo->firstVer;
|
return pInfo->firstVer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int64_t walGetCurFileLastVer(SWal* pWal) {
|
static inline int64_t walGetCurFileLastVer(SWal* pWal) {
|
||||||
|
if (pWal->writeCur == -1) return -1;
|
||||||
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur);
|
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur);
|
||||||
return pInfo->firstVer;
|
return pInfo->firstVer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int64_t walGetCurFileOffset(SWal* pWal) {
|
static inline int64_t walGetCurFileOffset(SWal* pWal) {
|
||||||
|
if (pWal->writeCur == -1) return -1;
|
||||||
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur);
|
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur);
|
||||||
return pInfo->fileSize;
|
return pInfo->fileSize;
|
||||||
}
|
}
|
||||||
|
@ -88,6 +93,7 @@ static inline int64_t walGetCurFileOffset(SWal* pWal) {
|
||||||
static inline bool walCurFileClosed(SWal* pWal) { return taosArrayGetSize(pWal->fileInfoSet) != pWal->writeCur; }
|
static inline bool walCurFileClosed(SWal* pWal) { return taosArrayGetSize(pWal->fileInfoSet) != pWal->writeCur; }
|
||||||
|
|
||||||
static inline SWalFileInfo* walGetCurFileInfo(SWal* pWal) {
|
static inline SWalFileInfo* walGetCurFileInfo(SWal* pWal) {
|
||||||
|
if (pWal->writeCur == -1) return NULL;
|
||||||
return (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur);
|
return (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import time
|
||||||
import socket
|
import socket
|
||||||
import json
|
import json
|
||||||
import toml
|
import toml
|
||||||
from .boundary import DataBoundary
|
from util.boundary import DataBoundary
|
||||||
import taos
|
import taos
|
||||||
from util.log import *
|
from util.log import *
|
||||||
from util.sql import *
|
from util.sql import *
|
||||||
|
@ -80,23 +80,18 @@ class DataSet:
|
||||||
self.bool_data.append( bool((i + bool_start) % 2 ))
|
self.bool_data.append( bool((i + bool_start) % 2 ))
|
||||||
self.vchar_data.append( f"{vchar_prefix}_{i * vchar_step}" )
|
self.vchar_data.append( f"{vchar_prefix}_{i * vchar_step}" )
|
||||||
self.nchar_data.append( f"{nchar_prefix}_{i * nchar_step}")
|
self.nchar_data.append( f"{nchar_prefix}_{i * nchar_step}")
|
||||||
self.ts_data.append( int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000 - i * ts_step))
|
self.ts_data.append( int(datetime.timestamp(datetime.now()) * 1000 - i * ts_step))
|
||||||
|
|
||||||
def get_disorder_set(self,
|
def get_disorder_set(self, rows, **kwargs):
|
||||||
rows,
|
for k, v in kwargs.items():
|
||||||
int_low :int = INT_MIN,
|
int_low = v if k == "int_low" else INT_MIN
|
||||||
int_up :int = INT_MAX,
|
int_up = v if k == "int_up" else INT_MAX
|
||||||
bint_low :int = BIGINT_MIN,
|
bint_low = v if k == "bint_low" else BIGINT_MIN
|
||||||
bint_up :int = BIGINT_MAX,
|
bint_up = v if k == "bint_up" else BIGINT_MAX
|
||||||
sint_low :int = SMALLINT_MIN,
|
sint_low = v if k == "sint_low" else SMALLINT_MIN
|
||||||
sint_up :int = SMALLINT_MAX,
|
sint_up = v if k == "sint_up" else SMALLINT_MAX
|
||||||
tint_low :int = TINYINT_MIN,
|
tint_low = v if k == "tint_low" else TINYINT_MIN
|
||||||
tint_up :int = TINYINT_MAX,
|
tint_up = v if k == "tint_up" else TINYINT_MAX
|
||||||
ubint_low :int = BIGINT_UN_MIN,
|
|
||||||
ubint_up :int = BIGINT_UN_MAX,
|
|
||||||
|
|
||||||
|
|
||||||
):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,18 +49,23 @@ class TDSql:
|
||||||
def close(self):
|
def close(self):
|
||||||
self.cursor.close()
|
self.cursor.close()
|
||||||
|
|
||||||
def prepare(self):
|
def prepare(self, dbname="db", drop=True, **kwargs):
|
||||||
tdLog.info("prepare database:db")
|
tdLog.info(f"prepare database:{dbname}")
|
||||||
s = 'reset query cache'
|
s = 'reset query cache'
|
||||||
try:
|
try:
|
||||||
self.cursor.execute(s)
|
self.cursor.execute(s)
|
||||||
except:
|
except:
|
||||||
tdLog.notice("'reset query cache' is not supported")
|
tdLog.notice("'reset query cache' is not supported")
|
||||||
s = 'drop database if exists db'
|
if drop:
|
||||||
|
s = f'drop database if exists {dbname}'
|
||||||
|
self.cursor.execute(s)
|
||||||
|
s = f'create database {dbname}'
|
||||||
|
for k, v in kwargs.items():
|
||||||
|
s += f" {k} {v}"
|
||||||
|
if "duration" not in kwargs:
|
||||||
|
s += " duration 300"
|
||||||
self.cursor.execute(s)
|
self.cursor.execute(s)
|
||||||
s = 'create database db duration 300'
|
s = f'use {dbname}'
|
||||||
self.cursor.execute(s)
|
|
||||||
s = 'use db'
|
|
||||||
self.cursor.execute(s)
|
self.cursor.execute(s)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
|
@ -106,7 +111,7 @@ class TDSql:
|
||||||
if row_tag:
|
if row_tag:
|
||||||
return self.queryResult
|
return self.queryResult
|
||||||
return self.queryRows
|
return self.queryRows
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
args = (caller.filename, caller.lineno, sql, repr(e))
|
args = (caller.filename, caller.lineno, sql, repr(e))
|
||||||
tdLog.notice("%s(%d) failed: sql:%s, %s" % args)
|
tdLog.notice("%s(%d) failed: sql:%s, %s" % args)
|
||||||
|
@ -304,7 +309,7 @@ class TDSql:
|
||||||
tdLog.notice("Try to execute sql again, query times: %d "%i)
|
tdLog.notice("Try to execute sql again, query times: %d "%i)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
tdLog.notice("Try the last execute sql ")
|
tdLog.notice("Try the last execute sql ")
|
||||||
self.affectedRows = self.cursor.execute(sql)
|
self.affectedRows = self.cursor.execute(sql)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
#======================b1-start===============
|
#======================b1-start===============
|
||||||
|
|
||||||
# ---- user
|
# ---- user ----
|
||||||
./test.sh -f tsim/user/basic.sim
|
./test.sh -f tsim/user/basic.sim
|
||||||
./test.sh -f tsim/user/password.sim
|
./test.sh -f tsim/user/password.sim
|
||||||
./test.sh -f tsim/user/privilege_db.sim
|
./test.sh -f tsim/user/privilege_db.sim
|
||||||
|
@ -58,13 +58,13 @@
|
||||||
# unsupport ./test.sh -f tsim/dnode/vnode_clean.sim
|
# unsupport ./test.sh -f tsim/dnode/vnode_clean.sim
|
||||||
./test.sh -f tsim/dnode/use_dropped_dnode.sim
|
./test.sh -f tsim/dnode/use_dropped_dnode.sim
|
||||||
|
|
||||||
# ---- import
|
# ---- import ----
|
||||||
./test.sh -f tsim/import/basic.sim
|
./test.sh -f tsim/import/basic.sim
|
||||||
./test.sh -f tsim/import/commit.sim
|
./test.sh -f tsim/import/commit.sim
|
||||||
./test.sh -f tsim/import/large.sim
|
./test.sh -f tsim/import/large.sim
|
||||||
./test.sh -f tsim/import/replica1.sim
|
./test.sh -f tsim/import/replica1.sim
|
||||||
|
|
||||||
# ---- insert
|
# ---- insert ----
|
||||||
./test.sh -f tsim/insert/backquote.sim
|
./test.sh -f tsim/insert/backquote.sim
|
||||||
./test.sh -f tsim/insert/basic.sim
|
./test.sh -f tsim/insert/basic.sim
|
||||||
./test.sh -f tsim/insert/basic0.sim
|
./test.sh -f tsim/insert/basic0.sim
|
||||||
|
@ -164,7 +164,7 @@
|
||||||
# TD-17704 ./test.sh -f tsim/parser/union_sysinfo.sim
|
# TD-17704 ./test.sh -f tsim/parser/union_sysinfo.sim
|
||||||
# TD-17661 ./test.sh -f tsim/parser/where.sim
|
# TD-17661 ./test.sh -f tsim/parser/where.sim
|
||||||
|
|
||||||
# ---- query
|
# ---- query ----
|
||||||
./test.sh -f tsim/query/charScalarFunction.sim
|
./test.sh -f tsim/query/charScalarFunction.sim
|
||||||
# ./test.sh -f tsim/query/explain.sim
|
# ./test.sh -f tsim/query/explain.sim
|
||||||
./test.sh -f tsim/query/interval-offset.sim
|
./test.sh -f tsim/query/interval-offset.sim
|
||||||
|
@ -187,10 +187,10 @@
|
||||||
./test.sh -f tsim/mnode/basic1.sim
|
./test.sh -f tsim/mnode/basic1.sim
|
||||||
./test.sh -f tsim/mnode/basic2.sim
|
./test.sh -f tsim/mnode/basic2.sim
|
||||||
./test.sh -f tsim/mnode/basic3.sim
|
./test.sh -f tsim/mnode/basic3.sim
|
||||||
./test.sh -f tsim/mnode/basic4.sim
|
# TD-17919 ./test.sh -f tsim/mnode/basic4.sim
|
||||||
./test.sh -f tsim/mnode/basic5.sim
|
./test.sh -f tsim/mnode/basic5.sim
|
||||||
|
|
||||||
# ---- show
|
# ---- show ----
|
||||||
./test.sh -f tsim/show/basic.sim
|
./test.sh -f tsim/show/basic.sim
|
||||||
|
|
||||||
# ---- table
|
# ---- table
|
||||||
|
@ -260,7 +260,7 @@
|
||||||
./test.sh -f tsim/tmq/snapshot.sim
|
./test.sh -f tsim/tmq/snapshot.sim
|
||||||
./test.sh -f tsim/tmq/snapshot1.sim
|
./test.sh -f tsim/tmq/snapshot1.sim
|
||||||
|
|
||||||
# --- stable
|
# --- stable ----
|
||||||
./test.sh -f tsim/stable/alter_comment.sim
|
./test.sh -f tsim/stable/alter_comment.sim
|
||||||
./test.sh -f tsim/stable/alter_count.sim
|
./test.sh -f tsim/stable/alter_count.sim
|
||||||
./test.sh -f tsim/stable/alter_import.sim
|
./test.sh -f tsim/stable/alter_import.sim
|
||||||
|
@ -274,7 +274,6 @@
|
||||||
./test.sh -f tsim/stable/dnode3.sim
|
./test.sh -f tsim/stable/dnode3.sim
|
||||||
./test.sh -f tsim/stable/metrics.sim
|
./test.sh -f tsim/stable/metrics.sim
|
||||||
./test.sh -f tsim/stable/refcount.sim
|
./test.sh -f tsim/stable/refcount.sim
|
||||||
./test.sh -f tsim/stable/show.sim
|
|
||||||
./test.sh -f tsim/stable/tag_add.sim
|
./test.sh -f tsim/stable/tag_add.sim
|
||||||
./test.sh -f tsim/stable/tag_drop.sim
|
./test.sh -f tsim/stable/tag_drop.sim
|
||||||
./test.sh -f tsim/stable/tag_filter.sim
|
./test.sh -f tsim/stable/tag_filter.sim
|
||||||
|
@ -298,8 +297,9 @@
|
||||||
# --- sma
|
# --- sma
|
||||||
./test.sh -f tsim/sma/drop_sma.sim
|
./test.sh -f tsim/sma/drop_sma.sim
|
||||||
./test.sh -f tsim/sma/tsmaCreateInsertQuery.sim
|
./test.sh -f tsim/sma/tsmaCreateInsertQuery.sim
|
||||||
./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim
|
# temp disable
|
||||||
./test.sh -f tsim/sma/rsmaPersistenceRecovery.sim
|
#./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim
|
||||||
|
#./test.sh -f tsim/sma/rsmaPersistenceRecovery.sim
|
||||||
|
|
||||||
# --- valgrind
|
# --- valgrind
|
||||||
./test.sh -f tsim/valgrind/checkError1.sim
|
./test.sh -f tsim/valgrind/checkError1.sim
|
||||||
|
@ -308,6 +308,7 @@
|
||||||
./test.sh -f tsim/valgrind/checkError4.sim
|
./test.sh -f tsim/valgrind/checkError4.sim
|
||||||
./test.sh -f tsim/valgrind/checkError5.sim
|
./test.sh -f tsim/valgrind/checkError5.sim
|
||||||
./test.sh -f tsim/valgrind/checkError6.sim
|
./test.sh -f tsim/valgrind/checkError6.sim
|
||||||
|
./test.sh -f tsim/valgrind/checkError7.sim
|
||||||
|
|
||||||
# --- vnode
|
# --- vnode
|
||||||
# unsupport ./test.sh -f tsim/vnode/replica3_basic.sim
|
# unsupport ./test.sh -f tsim/vnode/replica3_basic.sim
|
||||||
|
@ -328,35 +329,35 @@
|
||||||
./test.sh -f tsim/sync/oneReplica1VgElect.sim
|
./test.sh -f tsim/sync/oneReplica1VgElect.sim
|
||||||
./test.sh -f tsim/sync/oneReplica5VgElect.sim
|
./test.sh -f tsim/sync/oneReplica5VgElect.sim
|
||||||
|
|
||||||
# --- catalog
|
# --- catalog ----
|
||||||
./test.sh -f tsim/catalog/alterInCurrent.sim
|
./test.sh -f tsim/catalog/alterInCurrent.sim
|
||||||
|
|
||||||
# --- scalar
|
# --- scalar
|
||||||
./test.sh -f tsim/scalar/in.sim
|
./test.sh -f tsim/scalar/in.sim
|
||||||
./test.sh -f tsim/scalar/scalar.sim
|
./test.sh -f tsim/scalar/scalar.sim
|
||||||
|
|
||||||
# ---- alter
|
# ---- alter ----
|
||||||
./test.sh -f tsim/alter/cached_schema_after_alter.sim
|
./test.sh -f tsim/alter/cached_schema_after_alter.sim
|
||||||
./test.sh -f tsim/alter/dnode.sim
|
./test.sh -f tsim/alter/dnode.sim
|
||||||
./test.sh -f tsim/alter/table.sim
|
./test.sh -f tsim/alter/table.sim
|
||||||
|
|
||||||
# ---- cache
|
# ---- cache ----
|
||||||
./test.sh -f tsim/cache/new_metrics.sim
|
./test.sh -f tsim/cache/new_metrics.sim
|
||||||
./test.sh -f tsim/cache/restart_table.sim
|
./test.sh -f tsim/cache/restart_table.sim
|
||||||
./test.sh -f tsim/cache/restart_metrics.sim
|
./test.sh -f tsim/cache/restart_metrics.sim
|
||||||
|
|
||||||
# ---- column
|
# ---- column ----
|
||||||
./test.sh -f tsim/column/commit.sim
|
./test.sh -f tsim/column/commit.sim
|
||||||
./test.sh -f tsim/column/metrics.sim
|
./test.sh -f tsim/column/metrics.sim
|
||||||
./test.sh -f tsim/column/table.sim
|
./test.sh -f tsim/column/table.sim
|
||||||
|
|
||||||
# ---- compress
|
# ---- compress ----
|
||||||
./test.sh -f tsim/compress/commitlog.sim
|
./test.sh -f tsim/compress/commitlog.sim
|
||||||
./test.sh -f tsim/compress/compress2.sim
|
./test.sh -f tsim/compress/compress2.sim
|
||||||
./test.sh -f tsim/compress/compress.sim
|
./test.sh -f tsim/compress/compress.sim
|
||||||
./test.sh -f tsim/compress/uncompress.sim
|
./test.sh -f tsim/compress/uncompress.sim
|
||||||
|
|
||||||
# ---- compute
|
# ---- compute ----
|
||||||
./test.sh -f tsim/compute/avg.sim
|
./test.sh -f tsim/compute/avg.sim
|
||||||
./test.sh -f tsim/compute/block_dist.sim
|
./test.sh -f tsim/compute/block_dist.sim
|
||||||
./test.sh -f tsim/compute/bottom.sim
|
./test.sh -f tsim/compute/bottom.sim
|
||||||
|
|
|
@ -50,11 +50,8 @@ endi
|
||||||
|
|
||||||
print ================== restart server to commit data into disk
|
print ================== restart server to commit data into disk
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 3000
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
print ================== server restart completed
|
print ================== server restart completed
|
||||||
sleep 3000
|
|
||||||
sql connect
|
|
||||||
|
|
||||||
sql use $db
|
sql use $db
|
||||||
sql select * from $stb
|
sql select * from $stb
|
||||||
|
|
|
@ -45,8 +45,11 @@ endi
|
||||||
if $data(2)[4] != ready then
|
if $data(2)[4] != ready then
|
||||||
goto step2
|
goto step2
|
||||||
endi
|
endi
|
||||||
|
if $data(3)[4] != ready then
|
||||||
|
goto step2
|
||||||
|
endi
|
||||||
|
|
||||||
system sh/exec.sh -n dnode3 -s stop
|
system sh/exec.sh -n dnode3 -s stop -x SIGKILL
|
||||||
sql_error create mnode on dnode 3
|
sql_error create mnode on dnode 3
|
||||||
|
|
||||||
print =============== step3: show mnodes
|
print =============== step3: show mnodes
|
||||||
|
|
|
@ -51,40 +51,10 @@ endi
|
||||||
##TBASE-352
|
##TBASE-352
|
||||||
$offset = $tbNum * $rowNum
|
$offset = $tbNum * $rowNum
|
||||||
$offset = $offset - 1
|
$offset = $offset - 1
|
||||||
sql select * from $stb limit 2 offset $offset
|
sql select * from $stb order by ts limit 2 offset $offset
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data00 != @18-11-25 19:30:00.000@ then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data01 != 9 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data02 != NULL then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data03 != 9.00000 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data04 != NULL then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data05 != 9 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data06 != 9 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data07 != 1 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data08 != binary9 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data09 != nchar9 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
$offset = $tbNum * $rowNum
|
$offset = $tbNum * $rowNum
|
||||||
$offset = $offset / 2
|
$offset = $offset / 2
|
||||||
|
@ -207,21 +177,6 @@ sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17
|
||||||
if $rows != 5 then
|
if $rows != 5 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data01 != 5 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data11 != 6 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data21 != 7 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data31 != 8 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data41 != 4 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
$offset = $totalNum / 2
|
$offset = $totalNum / 2
|
||||||
sql select * from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset $offset
|
sql select * from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset $offset
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
|
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c wallevel -v 2
|
|
||||||
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
|
|
||||||
system sh/cfg.sh -n dnode1 -c udf -v 1
|
system sh/cfg.sh -n dnode1 -c udf -v 1
|
||||||
|
|
||||||
print ========= start dnode1 as leader
|
print ========= start dnode1 as leader
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 1000
|
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ======== step1 udf
|
print ======== step1 udf
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
system sh/stop_dnodes.sh
|
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
|
||||||
sql connect
|
|
||||||
|
|
||||||
print ======================== create stable
|
|
||||||
sql create database d1
|
|
||||||
sql use d1
|
|
||||||
|
|
||||||
$x = 0
|
|
||||||
while $x < 128
|
|
||||||
$tb = d1.s . $x
|
|
||||||
sql create table $tb (ts timestamp, i int) tags (j int)
|
|
||||||
$x = $x + 1
|
|
||||||
endw
|
|
||||||
|
|
||||||
print ======================== describe stables
|
|
||||||
# TODO : create stable error
|
|
||||||
$m = 0
|
|
||||||
while $m < 128
|
|
||||||
$tb = s . $m
|
|
||||||
$filter = ' . $tb
|
|
||||||
$filter = $filter . '
|
|
||||||
sql show stables like $filter
|
|
||||||
print sql : show stables like $filter
|
|
||||||
if $rows != 1 then
|
|
||||||
print expect 1, actual: $rows
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
$m = $m + 1
|
|
||||||
endw
|
|
||||||
|
|
||||||
|
|
||||||
print ======================== show stables
|
|
||||||
|
|
||||||
sql show d1.stables
|
|
||||||
|
|
||||||
print num of stables is $rows
|
|
||||||
if $rows != 128 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
print ======================== create table
|
|
||||||
|
|
||||||
$x = 0
|
|
||||||
while $x < 424
|
|
||||||
$tb = d1.t . $x
|
|
||||||
sql create table $tb using d1.s0 tags( $x )
|
|
||||||
$x = $x + 1
|
|
||||||
endw
|
|
||||||
|
|
||||||
print ======================== show stables
|
|
||||||
|
|
||||||
sql show d1.tables
|
|
||||||
|
|
||||||
print num of tables is $rows
|
|
||||||
if $rows != 424 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
|
@ -63,13 +63,15 @@ sql show table distributed tb1
|
||||||
sql select count(1) from tb1
|
sql select count(1) from tb1
|
||||||
sql select count(tbcol) as b from tb1 where ts <= 1601481840000 interval(1m)
|
sql select count(tbcol) as b from tb1 where ts <= 1601481840000 interval(1m)
|
||||||
sql select diff(tbcol) from tb1 where ts <= 1601481840000
|
sql select diff(tbcol) from tb1 where ts <= 1601481840000
|
||||||
sql select diff(tbcol) from tb1 where tbcol > 5 and tbcol < 20
|
sql select diff(tbcol) from tb1 where tbcol > 5 and tbcol < 20 order by ts
|
||||||
sql select first(tbcol), last(tbcol) as b from tb1 where ts <= 1601481840000 interval(1m)
|
sql select first(tbcol), last(tbcol) as b from tb1 where ts <= 1601481840000 interval(1m)
|
||||||
sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from tb1 where ts <= 1601481840000 partition by tgcol interval(1m)
|
sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from tb1 where ts <= 1601481840000 partition by tgcol order by tgcol
|
||||||
|
sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from tb1 where ts <= 1601481840000 partition by tgcol interval(1m)
|
||||||
sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0)
|
sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0)
|
||||||
sql select last_row(*) from tb1 where tbcol > 5 and tbcol < 20
|
sql select last_row(*) from tb1 where tbcol > 5 and tbcol < 20
|
||||||
sql select _wstart, _wend, _wduration, _qstart, _qend, count(*) from tb1 interval(10s, 2s) sliding(10s)
|
sql select _wstart, _wend, _wduration, _qstart, _qend, count(*) from tb1 interval(10s, 2s) sliding(10s)
|
||||||
sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0)
|
sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0)
|
||||||
|
sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from tb1 where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0) order by tgcol desc
|
||||||
sql select log(tbcol), abs(tbcol), pow(tbcol, 2), sqrt(tbcol), sin(tbcol), cos(tbcol), tan(tbcol), asin(tbcol), acos(tbcol), atan(tbcol), ceil(tbcol), floor(tbcol), round(tbcol), atan(tbcol) from tb1
|
sql select log(tbcol), abs(tbcol), pow(tbcol, 2), sqrt(tbcol), sin(tbcol), cos(tbcol), tan(tbcol), asin(tbcol), acos(tbcol), atan(tbcol), ceil(tbcol), floor(tbcol), round(tbcol), atan(tbcol) from tb1
|
||||||
sql select length("abcd1234"), char_length("abcd1234=-+*") from tb1
|
sql select length("abcd1234"), char_length("abcd1234=-+*") from tb1
|
||||||
sql select tbcol4, length(tbcol4), lower(tbcol4), upper(tbcol4), ltrim(tbcol4), rtrim(tbcol4), concat(tbcol4, tbcol5), concat_ws('_', tbcol4, tbcol5), substr(tbcol4, 1, 4) from tb1
|
sql select tbcol4, length(tbcol4), lower(tbcol4), upper(tbcol4), ltrim(tbcol4), rtrim(tbcol4), concat(tbcol4, tbcol5), concat_ws('_', tbcol4, tbcol5), substr(tbcol4, 1, 4) from tb1
|
||||||
|
@ -94,6 +96,7 @@ sql select first(tbcol), last(tbcol) as b from stb where ts <= 1601481840000 and
|
||||||
sql select first(tbcol), last(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m)
|
sql select first(tbcol), last(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m)
|
||||||
sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from stb where ts <= 1601481840000 partition by tgcol interval(1m)
|
sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from stb where ts <= 1601481840000 partition by tgcol interval(1m)
|
||||||
sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0)
|
sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 partition by tgcol interval(1m) fill(value, 0)
|
||||||
|
sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), count(tbcol) from stb where ts <= 1601481840000 and ts >= 1601481800000 and tgcol = 1 partition by tgcol interval(1m) fill(value, 0) order by tgcol desc
|
||||||
sql select last_row(tbcol), stddev(tbcol) from stb where tbcol > 5 and tbcol < 20 group by tgcol
|
sql select last_row(tbcol), stddev(tbcol) from stb where tbcol > 5 and tbcol < 20 group by tgcol
|
||||||
sql select _wstart, _wend, _wduration, _qstart, _qend, count(*) from stb interval(10s, 2s) sliding(10s)
|
sql select _wstart, _wend, _wduration, _qstart, _qend, count(*) from stb interval(10s, 2s) sliding(10s)
|
||||||
sql select log(tbcol), abs(tbcol), pow(tbcol, 2), sqrt(tbcol), sin(tbcol), cos(tbcol), tan(tbcol), asin(tbcol), acos(tbcol), atan(tbcol), ceil(tbcol), floor(tbcol), round(tbcol), atan(tbcol) from stb
|
sql select log(tbcol), abs(tbcol), pow(tbcol, 2), sqrt(tbcol), sin(tbcol), cos(tbcol), tan(tbcol), asin(tbcol), acos(tbcol), atan(tbcol), ceil(tbcol), floor(tbcol), round(tbcol), atan(tbcol) from stb
|
||||||
|
|
|
@ -0,0 +1,257 @@
|
||||||
|
from datetime import datetime
|
||||||
|
import time
|
||||||
|
|
||||||
|
from typing import List, Any, Tuple
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.dnodes import *
|
||||||
|
from util.common import *
|
||||||
|
|
||||||
|
PRIMARY_COL = "ts"
|
||||||
|
|
||||||
|
INT_COL = "c_int"
|
||||||
|
BINT_COL = "c_bint"
|
||||||
|
SINT_COL = "c_sint"
|
||||||
|
TINT_COL = "c_tint"
|
||||||
|
FLOAT_COL = "c_float"
|
||||||
|
DOUBLE_COL = "c_double"
|
||||||
|
BOOL_COL = "c_bool"
|
||||||
|
TINT_UN_COL = "c_utint"
|
||||||
|
SINT_UN_COL = "c_usint"
|
||||||
|
BINT_UN_COL = "c_ubint"
|
||||||
|
INT_UN_COL = "c_uint"
|
||||||
|
BINARY_COL = "c_binary"
|
||||||
|
NCHAR_COL = "c_nchar"
|
||||||
|
TS_COL = "c_ts"
|
||||||
|
|
||||||
|
NUM_COL = [INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ]
|
||||||
|
CHAR_COL = [BINARY_COL, NCHAR_COL, ]
|
||||||
|
BOOLEAN_COL = [BOOL_COL, ]
|
||||||
|
TS_TYPE_COL = [TS_COL, ]
|
||||||
|
|
||||||
|
INT_TAG = "t_int"
|
||||||
|
|
||||||
|
TAG_COL = [INT_TAG]
|
||||||
|
# insert data args:
|
||||||
|
TIME_STEP = 10000
|
||||||
|
NOW = int(datetime.timestamp(datetime.now()) * 1000)
|
||||||
|
|
||||||
|
# init db/table
|
||||||
|
DBNAME = "db"
|
||||||
|
STBNAME = "stb1"
|
||||||
|
CTB_PRE = "ct"
|
||||||
|
NTB_PRE = "nt"
|
||||||
|
|
||||||
|
L0 = 0
|
||||||
|
L1 = 1
|
||||||
|
L2 = 2
|
||||||
|
|
||||||
|
PRIMARY_DIR = 1
|
||||||
|
NON_PRIMARY_DIR = 0
|
||||||
|
|
||||||
|
DATA_PRE0 = f"data0"
|
||||||
|
DATA_PRE1 = f"data1"
|
||||||
|
DATA_PRE2 = f"data2"
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
|
||||||
|
def init(self, conn, logSql):
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
tdSql.init(conn.cursor(), False)
|
||||||
|
self.taos_cfg_path = tdDnodes.dnodes[0].cfgPath
|
||||||
|
self.taos_data_dir = tdDnodes.dnodes[0].dataDir
|
||||||
|
|
||||||
|
|
||||||
|
def cfg(self, filename, **update_dict):
|
||||||
|
cmd = "echo "
|
||||||
|
for k, v in update_dict.items():
|
||||||
|
cmd += f"{k} {v}\n"
|
||||||
|
|
||||||
|
cmd += f" >> {filename}"
|
||||||
|
if os.system(cmd) != 0:
|
||||||
|
tdLog.exit(cmd)
|
||||||
|
|
||||||
|
def cfg_str(self, filename, update_str):
|
||||||
|
cmd = f'echo "{update_str}" >> {filename}'
|
||||||
|
if os.system(cmd) != 0:
|
||||||
|
tdLog.exit(cmd)
|
||||||
|
|
||||||
|
def cfg_str_list(self, filename, update_list):
|
||||||
|
for update_str in update_list:
|
||||||
|
self.cfg_str(filename, update_str)
|
||||||
|
|
||||||
|
def del_old_datadir(self, filename):
|
||||||
|
cmd = f"sed -i '/^dataDir/d' {filename}"
|
||||||
|
if os.system(cmd) != 0:
|
||||||
|
tdLog.exit(cmd)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def __err_cfg(self):
|
||||||
|
cfg_list = []
|
||||||
|
err_case1 = [
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {NON_PRIMARY_DIR}",
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE1}1 {L1} {PRIMARY_DIR}",
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE2}2 {L2} {NON_PRIMARY_DIR}"
|
||||||
|
]
|
||||||
|
err_case2 = [
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {NON_PRIMARY_DIR}",
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE1}1 {L1} {NON_PRIMARY_DIR}",
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE2}2 {L2} {PRIMARY_DIR}"
|
||||||
|
]
|
||||||
|
err_case3 = [
|
||||||
|
f"dataDir {self.taos_data_dir}/data33 3 {NON_PRIMARY_DIR}"
|
||||||
|
]
|
||||||
|
err_case4 = [
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {NON_PRIMARY_DIR}",
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE1}1 {L1} {NON_PRIMARY_DIR}",
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE2}2 {L2} {NON_PRIMARY_DIR}",
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE2}2 {L1} {NON_PRIMARY_DIR}"
|
||||||
|
]
|
||||||
|
err_case5 = [f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {PRIMARY_DIR}"]
|
||||||
|
for i in range(16):
|
||||||
|
err_case5.append(f"dataDir {self.taos_data_dir}/{DATA_PRE0}{i+1} {L0} {NON_PRIMARY_DIR}")
|
||||||
|
|
||||||
|
err_case6 = [
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {PRIMARY_DIR}",
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE0}1 {L0} {PRIMARY_DIR}",
|
||||||
|
]
|
||||||
|
err_case7 = [
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {PRIMARY_DIR}",
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE2}2 {L2} {PRIMARY_DIR}",
|
||||||
|
]
|
||||||
|
err_case8 = [
|
||||||
|
f"dataDir {self.taos_data_dir}/data33 3 {PRIMARY_DIR}"
|
||||||
|
]
|
||||||
|
err_case9 = [
|
||||||
|
f"dataDir {self.taos_data_dir}/data33 -1 {NON_PRIMARY_DIR}"
|
||||||
|
]
|
||||||
|
|
||||||
|
cfg_list.append(err_case1)
|
||||||
|
cfg_list.append(err_case2)
|
||||||
|
cfg_list.append(err_case3)
|
||||||
|
cfg_list.append(err_case4)
|
||||||
|
cfg_list.append(err_case5)
|
||||||
|
cfg_list.append(err_case6)
|
||||||
|
cfg_list.append(err_case7)
|
||||||
|
cfg_list.append(err_case8)
|
||||||
|
cfg_list.append(err_case9)
|
||||||
|
|
||||||
|
return cfg_list
|
||||||
|
|
||||||
|
@property
|
||||||
|
def __current_cfg(self):
|
||||||
|
cfg_list = []
|
||||||
|
current_case1 = [
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {PRIMARY_DIR}",
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE0}1 {L0} {NON_PRIMARY_DIR}",
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE1}1 {L1} {NON_PRIMARY_DIR}",
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE2}2 {L2} {NON_PRIMARY_DIR}"
|
||||||
|
]
|
||||||
|
|
||||||
|
current_case2 = [f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {PRIMARY_DIR}"]
|
||||||
|
for i in range(9):
|
||||||
|
current_case2.append(f"dataDir {self.taos_data_dir}/{DATA_PRE0}{i+1} {L0} {NON_PRIMARY_DIR}")
|
||||||
|
|
||||||
|
# TD-17773bug
|
||||||
|
current_case3 = [
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 ",
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE0}1 {L0} {NON_PRIMARY_DIR}",
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE1}0 {L1} {NON_PRIMARY_DIR}",
|
||||||
|
f"dataDir {self.taos_data_dir}/{DATA_PRE2}0 {L2} {NON_PRIMARY_DIR}",
|
||||||
|
]
|
||||||
|
cfg_list.append(current_case1)
|
||||||
|
cfg_list.append(current_case3)
|
||||||
|
|
||||||
|
# case2 must in last of least, because use this cfg as data uniformity test
|
||||||
|
cfg_list.append(current_case2)
|
||||||
|
|
||||||
|
return cfg_list
|
||||||
|
|
||||||
|
def cfg_check(self):
|
||||||
|
for cfg_case in self.__err_cfg:
|
||||||
|
self.del_old_datadir(filename=self.taos_cfg_path)
|
||||||
|
tdDnodes.stop(1)
|
||||||
|
tdDnodes.deploy(1)
|
||||||
|
self.cfg_str_list(filename=self.taos_cfg_path, update_list=cfg_case)
|
||||||
|
tdDnodes.starttaosd(1)
|
||||||
|
time.sleep(2)
|
||||||
|
tdSql.error(f"show databases")
|
||||||
|
|
||||||
|
for cfg_case in self.__current_cfg:
|
||||||
|
self.del_old_datadir(filename=self.taos_cfg_path)
|
||||||
|
tdDnodes.stop(1)
|
||||||
|
tdDnodes.deploy(1)
|
||||||
|
self.cfg_str_list(filename=self.taos_cfg_path, update_list=cfg_case)
|
||||||
|
tdDnodes.start(1)
|
||||||
|
tdSql.query(f"show databases")
|
||||||
|
|
||||||
|
def __create_tb(self, stb=STBNAME, ctb_pre = CTB_PRE, ctb_num=20, ntb_pre=NTB_PRE, ntbnum=1, dbname=DBNAME):
|
||||||
|
tdLog.printNoPrefix("==========step: create table")
|
||||||
|
create_stb_sql = f'''create table {dbname}.{stb}(
|
||||||
|
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||||
|
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||||
|
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp,
|
||||||
|
{TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned,
|
||||||
|
{INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned
|
||||||
|
) tags ({INT_TAG} int)
|
||||||
|
'''
|
||||||
|
tdSql.execute(create_stb_sql)
|
||||||
|
|
||||||
|
for i in range(ntbnum):
|
||||||
|
create_ntb_sql = f'''create table {dbname}.{ntb_pre}{i+1}(
|
||||||
|
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||||
|
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||||
|
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp,
|
||||||
|
{TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned,
|
||||||
|
{INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned
|
||||||
|
)
|
||||||
|
'''
|
||||||
|
tdSql.execute(create_ntb_sql)
|
||||||
|
|
||||||
|
for i in range(ctb_num):
|
||||||
|
tdSql.execute(f'create table {dbname}.{ctb_pre}{i+1} using {dbname}.{stb} tags ( {i+1} )')
|
||||||
|
|
||||||
|
def __insert_data(self, rows, dbname=DBNAME, ctb_num=20):
|
||||||
|
data = DataSet()
|
||||||
|
data.get_order_set(rows)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("==========step: start inser data into tables now.....")
|
||||||
|
for i in range(self.rows):
|
||||||
|
row_data = f'''
|
||||||
|
{data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]},
|
||||||
|
{data.bool_data[i]}, '{data.vchar_data[i]}', '{data.nchar_data[i]}', {data.ts_data[i]}, {data.utint_data[i]},
|
||||||
|
{data.usint_data[i]}, {data.uint_data[i]}, {data.ubint_data[i]}
|
||||||
|
'''
|
||||||
|
neg_row_data = f'''
|
||||||
|
{-1 * data.int_data[i]}, {-1 * data.bint_data[i]}, {-1 * data.sint_data[i]}, {-1 * data.tint_data[i]}, {-1 * data.float_data[i]}, {-1 * data.double_data[i]},
|
||||||
|
{data.bool_data[i]}, '{data.vchar_data[i]}', '{data.nchar_data[i]}', {data.ts_data[i]}, {1 * data.utint_data[i]},
|
||||||
|
{1 * data.usint_data[i]}, {1 * data.uint_data[i]}, {1 * data.ubint_data[i]}
|
||||||
|
'''
|
||||||
|
|
||||||
|
for j in range(ctb_num):
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into {dbname}.{CTB_PRE}{j + 1} values ( {NOW - i * TIME_STEP}, {row_data} )")
|
||||||
|
|
||||||
|
# tdSql.execute(
|
||||||
|
# f"insert into {dbname}.{CTB_PRE}2 values ( {NOW - i * int(TIME_STEP * 0.6)}, {neg_row_data} )")
|
||||||
|
# tdSql.execute(
|
||||||
|
# f"insert into {dbname}.{CTB_PRE}4 values ( {NOW - i * int(TIME_STEP * 0.8) }, {row_data} )")
|
||||||
|
tdSql.execute(
|
||||||
|
f"insert into {dbname}.{NTB_PRE}1 values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )")
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.rows = 10
|
||||||
|
self.cfg_check()
|
||||||
|
tdSql.prepare(dbname=DBNAME, **{"keep": "1d, 1500m, 26h", "duration":"1h", "vgroups": 10})
|
||||||
|
self.__create_tb(dbname=DBNAME)
|
||||||
|
self.__insert_data(rows=self.rows, dbname=DBNAME)
|
||||||
|
tdSql.query(f"select count(*) from {DBNAME}.{NTB_PRE}1")
|
||||||
|
tdSql.execute(f"flush database {DBNAME}")
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -1,4 +1,5 @@
|
||||||
import datetime
|
import datetime
|
||||||
|
import time
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import List, Any, Tuple
|
from typing import List, Any, Tuple
|
||||||
|
@ -328,11 +329,15 @@ class TDTestCase:
|
||||||
tdSql.query("select database()")
|
tdSql.query("select database()")
|
||||||
dbname = tdSql.getData(0,0)
|
dbname = tdSql.getData(0,0)
|
||||||
tdSql.query("show databases")
|
tdSql.query("show databases")
|
||||||
|
for index , value in enumerate(tdSql.cursor.description):
|
||||||
|
if value[0] == "retention":
|
||||||
|
r_index = index
|
||||||
|
break
|
||||||
for row in tdSql.queryResult:
|
for row in tdSql.queryResult:
|
||||||
if row[0] == dbname:
|
if row[0] == dbname:
|
||||||
if row[-1] is None:
|
if row[r_index] is None:
|
||||||
continue
|
continue
|
||||||
if ":" in row[-1]:
|
if ":" in row[r_index]:
|
||||||
sma.rollup_db = True
|
sma.rollup_db = True
|
||||||
if sma.rollup_db :
|
if sma.rollup_db :
|
||||||
return False
|
return False
|
||||||
|
@ -393,8 +398,6 @@ class TDTestCase:
|
||||||
else:
|
else:
|
||||||
tdSql.error(self.__create_sma_index(sma))
|
tdSql.error(self.__create_sma_index(sma))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __drop_sma_index(self, sma:SMAschema):
|
def __drop_sma_index(self, sma:SMAschema):
|
||||||
sql = f"{sma.drop} {sma.drop_flag} {sma.index_name}"
|
sql = f"{sma.drop} {sma.drop_flag} {sma.index_name}"
|
||||||
return sql
|
return sql
|
||||||
|
@ -416,8 +419,7 @@ class TDTestCase:
|
||||||
self.sma_created_index = list(filter(lambda x: x != sma.index_name, self.sma_created_index))
|
self.sma_created_index = list(filter(lambda x: x != sma.index_name, self.sma_created_index))
|
||||||
tdSql.query("show streams")
|
tdSql.query("show streams")
|
||||||
tdSql.checkRows(self.sma_count)
|
tdSql.checkRows(self.sma_count)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
tdSql.error(self.__drop_sma_index(sma))
|
tdSql.error(self.__drop_sma_index(sma))
|
||||||
|
|
||||||
|
|
|
@ -136,23 +136,23 @@ class TDTestCase:
|
||||||
|
|
||||||
return sqls
|
return sqls
|
||||||
|
|
||||||
def __test_current(self): # sourcery skip: use-itertools-product
|
def __test_current(self, dbname="db"): # sourcery skip: use-itertools-product
|
||||||
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
|
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
|
||||||
tbname = [
|
tbname = [
|
||||||
"ct1",
|
f"{dbname}.ct1",
|
||||||
"ct2",
|
f"{dbname}.ct2",
|
||||||
"ct4",
|
f"{dbname}.ct4",
|
||||||
]
|
]
|
||||||
for tb in tbname:
|
for tb in tbname:
|
||||||
for i in range(2,8):
|
for i in range(2,8):
|
||||||
self.__concat_check(tb,i)
|
self.__concat_check(tb,i)
|
||||||
tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========")
|
tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========")
|
||||||
|
|
||||||
def __test_error(self):
|
def __test_error(self, dbname="db"):
|
||||||
tdLog.printNoPrefix("==========err sql condition check , must return error==========")
|
tdLog.printNoPrefix("==========err sql condition check , must return error==========")
|
||||||
tbname = [
|
tbname = [
|
||||||
"t1",
|
f"{dbname}.t1",
|
||||||
"stb1",
|
f"{dbname}.stb1",
|
||||||
]
|
]
|
||||||
|
|
||||||
for tb in tbname:
|
for tb in tbname:
|
||||||
|
@ -163,22 +163,20 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
|
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
|
||||||
|
|
||||||
|
|
||||||
def all_test(self):
|
def all_test(self, dbname="db"):
|
||||||
self.__test_current()
|
self.__test_current(dbname)
|
||||||
self.__test_error()
|
self.__test_error(dbname)
|
||||||
|
|
||||||
|
def __create_tb(self, dbname="db"):
|
||||||
def __create_tb(self):
|
|
||||||
tdSql.prepare()
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step1:create table")
|
tdLog.printNoPrefix("==========step1:create table")
|
||||||
create_stb_sql = f'''create table stb1(
|
create_stb_sql = f'''create table {dbname}.stb1(
|
||||||
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 (t1 int)
|
||||||
'''
|
'''
|
||||||
create_ntb_sql = f'''create table t1(
|
create_ntb_sql = f'''create table {dbname}.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,
|
||||||
{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
|
||||||
|
@ -188,29 +186,29 @@ class TDTestCase:
|
||||||
tdSql.execute(create_ntb_sql)
|
tdSql.execute(create_ntb_sql)
|
||||||
|
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
|
||||||
|
|
||||||
def __insert_data(self, rows):
|
def __insert_data(self, rows, dbname="db"):
|
||||||
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into ct1 values
|
f'''insert into {dbname}.ct1 values
|
||||||
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
|
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
|
||||||
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
|
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into ct4 values
|
f'''insert into {dbname}.ct4 values
|
||||||
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
|
@ -226,7 +224,7 @@ class TDTestCase:
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into ct2 values
|
f'''insert into {dbname}.ct2 values
|
||||||
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
|
@ -242,13 +240,13 @@ class TDTestCase:
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
insert_data = f'''insert into t1 values
|
insert_data = f'''insert into {dbname}.t1 values
|
||||||
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
|
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
|
||||||
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
|
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
|
||||||
'''
|
'''
|
||||||
tdSql.execute(insert_data)
|
tdSql.execute(insert_data)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into t1 values
|
f'''insert into {dbname}.t1 values
|
||||||
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
|
@ -268,22 +266,23 @@ class TDTestCase:
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step1:create table")
|
tdLog.printNoPrefix("==========step1:create table")
|
||||||
self.__create_tb()
|
self.__create_tb(dbname="db")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step2:insert data")
|
tdLog.printNoPrefix("==========step2:insert data")
|
||||||
self.rows = 10
|
self.rows = 10
|
||||||
self.__insert_data(self.rows)
|
self.__insert_data(self.rows, dbname="db")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step3:all check")
|
tdLog.printNoPrefix("==========step3:all check")
|
||||||
self.all_test()
|
self.all_test(dbname="db")
|
||||||
|
|
||||||
tdDnodes.stop(1)
|
# tdDnodes.stop(1)
|
||||||
tdDnodes.start(1)
|
# tdDnodes.start(1)
|
||||||
|
tdSql.execute("flush database db")
|
||||||
|
|
||||||
tdSql.execute("use db")
|
tdSql.execute("use db")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
||||||
self.all_test()
|
self.all_test(dbname="db")
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -137,22 +137,22 @@ class TDTestCase:
|
||||||
|
|
||||||
return sqls
|
return sqls
|
||||||
|
|
||||||
def __test_current(self): # sourcery skip: use-itertools-product
|
def __test_current(self, dbname="db"):
|
||||||
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
|
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
|
||||||
tbname = [
|
tbname = [
|
||||||
"t1",
|
f"{dbname}.t1",
|
||||||
"stb1",
|
f"{dbname}.stb1",
|
||||||
]
|
]
|
||||||
for tb in tbname:
|
for tb in tbname:
|
||||||
for i in range(2,8):
|
for i in range(2,8):
|
||||||
self.__concat_check(tb,i)
|
self.__concat_check(tb,i)
|
||||||
tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========")
|
tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========")
|
||||||
|
|
||||||
def __test_error(self):
|
def __test_error(self, dbname="db"):
|
||||||
tdLog.printNoPrefix("==========err sql condition check , must return error==========")
|
tdLog.printNoPrefix("==========err sql condition check , must return error==========")
|
||||||
tbname = [
|
tbname = [
|
||||||
"ct1",
|
f"{dbname}.ct1",
|
||||||
"ct4",
|
f"{dbname}.ct4",
|
||||||
]
|
]
|
||||||
|
|
||||||
for tb in tbname:
|
for tb in tbname:
|
||||||
|
@ -163,22 +163,20 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
|
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
|
||||||
|
|
||||||
|
|
||||||
def all_test(self):
|
def all_test(self, dbname="db"):
|
||||||
self.__test_current()
|
self.__test_current(dbname)
|
||||||
self.__test_error()
|
self.__test_error(dbname)
|
||||||
|
|
||||||
|
def __create_tb(self, dbname="db"):
|
||||||
def __create_tb(self):
|
|
||||||
tdSql.prepare()
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step1:create table")
|
tdLog.printNoPrefix("==========step1:create table")
|
||||||
create_stb_sql = f'''create table stb1(
|
create_stb_sql = f'''create table {dbname}.stb1(
|
||||||
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 (t1 int)
|
||||||
'''
|
'''
|
||||||
create_ntb_sql = f'''create table t1(
|
create_ntb_sql = f'''create table {dbname}.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,
|
||||||
{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
|
||||||
|
@ -188,29 +186,29 @@ class TDTestCase:
|
||||||
tdSql.execute(create_ntb_sql)
|
tdSql.execute(create_ntb_sql)
|
||||||
|
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
|
||||||
|
|
||||||
def __insert_data(self, rows):
|
def __insert_data(self, rows, dbname="db"):
|
||||||
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into ct1 values
|
f'''insert into {dbname}.ct1 values
|
||||||
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
|
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
|
||||||
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
|
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into ct4 values
|
f'''insert into {dbname}.ct4 values
|
||||||
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
|
@ -226,7 +224,7 @@ class TDTestCase:
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into ct2 values
|
f'''insert into {dbname}.ct2 values
|
||||||
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
|
@ -242,13 +240,13 @@ class TDTestCase:
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
insert_data = f'''insert into t1 values
|
insert_data = f'''insert into {dbname}.t1 values
|
||||||
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
|
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
|
||||||
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
|
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
|
||||||
'''
|
'''
|
||||||
tdSql.execute(insert_data)
|
tdSql.execute(insert_data)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into t1 values
|
f'''insert into {dbname}.t1 values
|
||||||
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
|
@ -268,23 +266,23 @@ class TDTestCase:
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step1:create table")
|
tdLog.printNoPrefix("==========step1:create table")
|
||||||
self.__create_tb()
|
self.__create_tb(dbname="db")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step2:insert data")
|
tdLog.printNoPrefix("==========step2:insert data")
|
||||||
self.rows = 10
|
self.rows = 10
|
||||||
self.__insert_data(self.rows)
|
self.__insert_data(self.rows, dbname="db")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step3:all check")
|
tdLog.printNoPrefix("==========step3:all check")
|
||||||
self.all_test()
|
self.all_test(dbname="db")
|
||||||
|
|
||||||
tdDnodes.stop(1)
|
# tdDnodes.stop(1)
|
||||||
tdDnodes.start(1)
|
# tdDnodes.start(1)
|
||||||
|
tdSql.execute("flush database db")
|
||||||
|
|
||||||
tdSql.execute("use db")
|
tdSql.execute("use db")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
||||||
self.all_test()
|
self.all_test(dbname="db")
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
tdLog.success(f"{__file__} successfully executed")
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
|
@ -137,23 +137,23 @@ class TDTestCase:
|
||||||
|
|
||||||
return sqls
|
return sqls
|
||||||
|
|
||||||
def __test_current(self): # sourcery skip: use-itertools-product
|
def __test_current(self,dbname="db"): # sourcery skip: use-itertools-product
|
||||||
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
|
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
|
||||||
tbname = [
|
tbname = [
|
||||||
"t1",
|
f"{dbname}.t1",
|
||||||
"stb1"
|
f"{dbname}.stb1"
|
||||||
]
|
]
|
||||||
for tb in tbname:
|
for tb in tbname:
|
||||||
for i in range(2,8):
|
for i in range(2,8):
|
||||||
self.__concat_ws_check(tb,i)
|
self.__concat_ws_check(tb,i)
|
||||||
tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========")
|
tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========")
|
||||||
|
|
||||||
def __test_error(self):
|
def __test_error(self, dbname="db"):
|
||||||
tdLog.printNoPrefix("==========err sql condition check , must return error==========")
|
tdLog.printNoPrefix("==========err sql condition check , must return error==========")
|
||||||
tbname = [
|
tbname = [
|
||||||
"ct1",
|
f"{dbname}.ct1",
|
||||||
"ct2",
|
f"{dbname}.ct2",
|
||||||
"ct4",
|
f"{dbname}.ct4",
|
||||||
]
|
]
|
||||||
|
|
||||||
for tb in tbname:
|
for tb in tbname:
|
||||||
|
@ -164,22 +164,21 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
|
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
|
||||||
|
|
||||||
|
|
||||||
def all_test(self):
|
def all_test(self,dbname="db"):
|
||||||
self.__test_current()
|
self.__test_current(dbname)
|
||||||
self.__test_error()
|
self.__test_error(dbname)
|
||||||
|
|
||||||
|
|
||||||
def __create_tb(self):
|
def __create_tb(self, dbname="db"):
|
||||||
tdSql.prepare()
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step1:create table")
|
tdLog.printNoPrefix("==========step1:create table")
|
||||||
create_stb_sql = f'''create table stb1(
|
create_stb_sql = f'''create table {dbname}.stb1(
|
||||||
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 (t1 int)
|
||||||
'''
|
'''
|
||||||
create_ntb_sql = f'''create table t1(
|
create_ntb_sql = f'''create table {dbname}.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,
|
||||||
{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
|
||||||
|
@ -189,29 +188,29 @@ class TDTestCase:
|
||||||
tdSql.execute(create_ntb_sql)
|
tdSql.execute(create_ntb_sql)
|
||||||
|
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
|
||||||
|
|
||||||
def __insert_data(self, rows):
|
def __insert_data(self, rows, dbname="db"):
|
||||||
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into ct1 values
|
f'''insert into {dbname}.ct1 values
|
||||||
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
|
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
|
||||||
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
|
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into ct4 values
|
f'''insert into {dbname}.ct4 values
|
||||||
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
|
@ -227,7 +226,7 @@ class TDTestCase:
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into ct2 values
|
f'''insert into {dbname}.ct2 values
|
||||||
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
|
@ -243,13 +242,13 @@ class TDTestCase:
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
insert_data = f'''insert into t1 values
|
insert_data = f'''insert into {dbname}.t1 values
|
||||||
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
|
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
|
||||||
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
|
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
|
||||||
'''
|
'''
|
||||||
tdSql.execute(insert_data)
|
tdSql.execute(insert_data)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into t1 values
|
f'''insert into {dbname}.t1 values
|
||||||
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
|
@ -269,22 +268,23 @@ class TDTestCase:
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step1:create table")
|
tdLog.printNoPrefix("==========step1:create table")
|
||||||
self.__create_tb()
|
self.__create_tb(dbname="db")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step2:insert data")
|
tdLog.printNoPrefix("==========step2:insert data")
|
||||||
self.rows = 10
|
self.rows = 10
|
||||||
self.__insert_data(self.rows)
|
self.__insert_data(self.rows, dbname="db")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step3:all check")
|
tdLog.printNoPrefix("==========step3:all check")
|
||||||
self.all_test()
|
self.all_test(dbname="db")
|
||||||
|
|
||||||
tdDnodes.stop(1)
|
# tdDnodes.stop(1)
|
||||||
tdDnodes.start(1)
|
# tdDnodes.start(1)
|
||||||
|
tdSql.execute("flush database db")
|
||||||
|
|
||||||
tdSql.execute("use db")
|
tdSql.execute("use db")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
||||||
self.all_test()
|
self.all_test(dbname="db")
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -137,23 +137,23 @@ class TDTestCase:
|
||||||
|
|
||||||
return sqls
|
return sqls
|
||||||
|
|
||||||
def __test_current(self): # sourcery skip: use-itertools-product
|
def __test_current(self, dbname="db"): # sourcery skip: use-itertools-product
|
||||||
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
|
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
|
||||||
tbname = [
|
tbname = [
|
||||||
"ct1",
|
f"{dbname}.ct1",
|
||||||
"ct2",
|
f"{dbname}.ct2",
|
||||||
"ct4",
|
f"{dbname}.ct4",
|
||||||
]
|
]
|
||||||
for tb in tbname:
|
for tb in tbname:
|
||||||
for i in range(2,8):
|
for i in range(2,8):
|
||||||
self.__concat_ws_check(tb,i)
|
self.__concat_ws_check(tb,i)
|
||||||
tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========")
|
tdLog.printNoPrefix(f"==========current sql condition check in {tb}, col num: {i} over==========")
|
||||||
|
|
||||||
def __test_error(self):
|
def __test_error(self, dbname="db"):
|
||||||
tdLog.printNoPrefix("==========err sql condition check , must return error==========")
|
tdLog.printNoPrefix("==========err sql condition check , must return error==========")
|
||||||
tbname = [
|
tbname = [
|
||||||
"t1",
|
f"{dbname}.t1",
|
||||||
"stb1"
|
f"{dbname}.stb1"
|
||||||
]
|
]
|
||||||
|
|
||||||
for tb in tbname:
|
for tb in tbname:
|
||||||
|
@ -164,22 +164,21 @@ class TDTestCase:
|
||||||
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
|
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
|
||||||
|
|
||||||
|
|
||||||
def all_test(self):
|
def all_test(self, dbname="db"):
|
||||||
self.__test_current()
|
self.__test_current(dbname="db")
|
||||||
self.__test_error()
|
self.__test_error(dbname="db")
|
||||||
|
|
||||||
|
|
||||||
def __create_tb(self):
|
def __create_tb(self, dbname="db"):
|
||||||
tdSql.prepare()
|
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step1:create table")
|
tdLog.printNoPrefix("==========step1:create table")
|
||||||
create_stb_sql = f'''create table stb1(
|
create_stb_sql = f'''create table {dbname}.stb1(
|
||||||
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 (t1 int)
|
||||||
'''
|
'''
|
||||||
create_ntb_sql = f'''create table t1(
|
create_ntb_sql = f'''create table {dbname}.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,
|
||||||
{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
|
||||||
|
@ -189,29 +188,29 @@ class TDTestCase:
|
||||||
tdSql.execute(create_ntb_sql)
|
tdSql.execute(create_ntb_sql)
|
||||||
|
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
|
||||||
|
|
||||||
def __insert_data(self, rows):
|
def __insert_data(self, rows, dbname="db"):
|
||||||
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into ct1 values
|
f'''insert into {dbname}.ct1 values
|
||||||
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
|
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
|
||||||
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
|
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into ct4 values
|
f'''insert into {dbname}.ct4 values
|
||||||
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
|
@ -227,7 +226,7 @@ class TDTestCase:
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into ct2 values
|
f'''insert into {dbname}.ct2 values
|
||||||
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
|
@ -243,13 +242,13 @@ class TDTestCase:
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
insert_data = f'''insert into t1 values
|
insert_data = f'''insert into {dbname}.t1 values
|
||||||
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
|
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
|
||||||
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
|
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
|
||||||
'''
|
'''
|
||||||
tdSql.execute(insert_data)
|
tdSql.execute(insert_data)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into t1 values
|
f'''insert into {dbname}.t1 values
|
||||||
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
|
@ -269,22 +268,23 @@ class TDTestCase:
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step1:create table")
|
tdLog.printNoPrefix("==========step1:create table")
|
||||||
self.__create_tb()
|
self.__create_tb(dbname="db")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step2:insert data")
|
tdLog.printNoPrefix("==========step2:insert data")
|
||||||
self.rows = 10
|
self.rows = 10
|
||||||
self.__insert_data(self.rows)
|
self.__insert_data(self.rows, dbname="db")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step3:all check")
|
tdLog.printNoPrefix("==========step3:all check")
|
||||||
self.all_test()
|
self.all_test(dbname="db")
|
||||||
|
|
||||||
tdDnodes.stop(1)
|
# tdDnodes.stop(1)
|
||||||
tdDnodes.start(1)
|
# tdDnodes.start(1)
|
||||||
|
tdSql.execute("flush database db")
|
||||||
|
|
||||||
tdSql.execute("use db")
|
tdSql.execute("use db")
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
||||||
self.all_test()
|
self.all_test(dbname="db")
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -9,48 +9,48 @@ from util.cases import *
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
|
# updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
|
||||||
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
|
# "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
|
||||||
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143}
|
# "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143}
|
||||||
def init(self, conn, powSql):
|
def init(self, conn, powSql):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
tdSql.init(conn.cursor())
|
tdSql.init(conn.cursor())
|
||||||
|
|
||||||
def prepare_datas(self):
|
def prepare_datas(self, dbname="db"):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
'''create table stb1
|
f'''create table {dbname}.stb1
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||||
tags (t1 int)
|
tags (t1 int)
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
'''
|
f'''
|
||||||
create table t1
|
create table {dbname}.t1
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
|
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||||
)
|
)
|
||||||
tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
|
|
||||||
tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
|
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f'''insert into t1 values
|
f'''insert into {dbname}.t1 values
|
||||||
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||||
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
|
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
|
||||||
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
||||||
|
@ -84,12 +84,17 @@ class TDTestCase:
|
||||||
auto_result.append(row_check)
|
auto_result.append(row_check)
|
||||||
|
|
||||||
check_status = True
|
check_status = True
|
||||||
|
print("========",pow_query, origin_query )
|
||||||
|
|
||||||
for row_index , row in enumerate(pow_result):
|
for row_index , row in enumerate(pow_result):
|
||||||
for col_index , elem in enumerate(row):
|
for col_index , elem in enumerate(row):
|
||||||
if auto_result[row_index][col_index] == None and not (auto_result[row_index][col_index] == None and elem == None):
|
if auto_result[row_index][col_index] == None and elem:
|
||||||
check_status = False
|
check_status = False
|
||||||
elif auto_result[row_index][col_index] != None and (auto_result[row_index][col_index] - elem > 0.00000001):
|
elif auto_result[row_index][col_index] != None and ((auto_result[row_index][col_index] != elem) and (str(auto_result[row_index][col_index])[:6] != str(elem)[:6] )):
|
||||||
|
# elif auto_result[row_index][col_index] != None and (abs(auto_result[row_index][col_index] - elem) > 0.000001):
|
||||||
|
print("=====")
|
||||||
|
print(row_index, col_index)
|
||||||
|
print(auto_result[row_index][col_index], elem, origin_result[row_index][col_index])
|
||||||
check_status = False
|
check_status = False
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
@ -99,68 +104,68 @@ class TDTestCase:
|
||||||
else:
|
else:
|
||||||
tdLog.info("cos value check pass , it work as expected ,sql is \"%s\" "%pow_query )
|
tdLog.info("cos value check pass , it work as expected ,sql is \"%s\" "%pow_query )
|
||||||
|
|
||||||
def test_errors(self):
|
def test_errors(self, dbname="db"):
|
||||||
error_sql_lists = [
|
error_sql_lists = [
|
||||||
"select cos from t1",
|
f"select cos from {dbname}.t1",
|
||||||
# "select cos(-+--+c1 ) from t1",
|
# f"select cos(-+--+c1 ) from {dbname}.t1",
|
||||||
# "select +-cos(c1) from t1",
|
# f"select +-cos(c1) from {dbname}.t1",
|
||||||
# "select ++-cos(c1) from t1",
|
# f"select ++-cos(c1) from {dbname}.t1",
|
||||||
# "select ++--cos(c1) from t1",
|
# f"select ++--cos(c1) from {dbname}.t1",
|
||||||
# "select - -cos(c1)*0 from t1",
|
# f"select - -cos(c1)*0 from {dbname}.t1",
|
||||||
# "select cos(tbname+1) from t1 ",
|
# f"select cos(tbname+1) from {dbname}.t1 ",
|
||||||
"select cos(123--123)==1 from t1",
|
f"select cos(123--123)==1 from {dbname}.t1",
|
||||||
"select cos(c1) as 'd1' from t1",
|
f"select cos(c1) as 'd1' from {dbname}.t1",
|
||||||
"select cos(c1 ,c2) from t1",
|
f"select cos(c1 ,c2) from {dbname}.t1",
|
||||||
"select cos(c1 ,NULL ) from t1",
|
f"select cos(c1 ,NULL ) from {dbname}.t1",
|
||||||
"select cos(,) from t1;",
|
f"select cos(,) from {dbname}.t1;",
|
||||||
"select cos(cos(c1) ab from t1)",
|
f"select cos(cos(c1) ab from {dbname}.t1)",
|
||||||
"select cos(c1 ) as int from t1",
|
f"select cos(c1 ) as int from {dbname}.t1",
|
||||||
"select cos from stb1",
|
f"select cos from {dbname}.stb1",
|
||||||
# "select cos(-+--+c1) from stb1",
|
# f"select cos(-+--+c1) from {dbname}.stb1",
|
||||||
# "select +-cos(c1) from stb1",
|
# f"select +-cos(c1) from {dbname}.stb1",
|
||||||
# "select ++-cos(c1) from stb1",
|
# f"select ++-cos(c1) from {dbname}.stb1",
|
||||||
# "select ++--cos(c1) from stb1",
|
# f"select ++--cos(c1) from {dbname}.stb1",
|
||||||
# "select - -cos(c1)*0 from stb1",
|
# f"select - -cos(c1)*0 from {dbname}.stb1",
|
||||||
# "select cos(tbname+1) from stb1 ",
|
# f"select cos(tbname+1) from {dbname}.stb1 ",
|
||||||
"select cos(123--123)==1 from stb1",
|
f"select cos(123--123)==1 from {dbname}.stb1",
|
||||||
"select cos(c1) as 'd1' from stb1",
|
f"select cos(c1) as 'd1' from {dbname}.stb1",
|
||||||
"select cos(c1 ,c2 ) from stb1",
|
f"select cos(c1 ,c2 ) from {dbname}.stb1",
|
||||||
"select cos(c1 ,NULL) from stb1",
|
f"select cos(c1 ,NULL) from {dbname}.stb1",
|
||||||
"select cos(,) from stb1;",
|
f"select cos(,) from {dbname}.stb1;",
|
||||||
"select cos(cos(c1) ab from stb1)",
|
f"select cos(cos(c1) ab from {dbname}.stb1)",
|
||||||
"select cos(c1) as int from stb1"
|
f"select cos(c1) as int from {dbname}.stb1"
|
||||||
]
|
]
|
||||||
for error_sql in error_sql_lists:
|
for error_sql in error_sql_lists:
|
||||||
tdSql.error(error_sql)
|
tdSql.error(error_sql)
|
||||||
|
|
||||||
def support_types(self):
|
def support_types(self, dbname="db"):
|
||||||
type_error_sql_lists = [
|
type_error_sql_lists = [
|
||||||
"select cos(ts) from t1" ,
|
f"select cos(ts) from {dbname}.t1" ,
|
||||||
"select cos(c7) from t1",
|
f"select cos(c7) from {dbname}.t1",
|
||||||
"select cos(c8) from t1",
|
f"select cos(c8) from {dbname}.t1",
|
||||||
"select cos(c9) from t1",
|
f"select cos(c9) from {dbname}.t1",
|
||||||
"select cos(ts) from ct1" ,
|
f"select cos(ts) from {dbname}.ct1" ,
|
||||||
"select cos(c7) from ct1",
|
f"select cos(c7) from {dbname}.ct1",
|
||||||
"select cos(c8) from ct1",
|
f"select cos(c8) from {dbname}.ct1",
|
||||||
"select cos(c9) from ct1",
|
f"select cos(c9) from {dbname}.ct1",
|
||||||
"select cos(ts) from ct3" ,
|
f"select cos(ts) from {dbname}.ct3" ,
|
||||||
"select cos(c7) from ct3",
|
f"select cos(c7) from {dbname}.ct3",
|
||||||
"select cos(c8) from ct3",
|
f"select cos(c8) from {dbname}.ct3",
|
||||||
"select cos(c9) from ct3",
|
f"select cos(c9) from {dbname}.ct3",
|
||||||
"select cos(ts) from ct4" ,
|
f"select cos(ts) from {dbname}.ct4" ,
|
||||||
"select cos(c7) from ct4",
|
f"select cos(c7) from {dbname}.ct4",
|
||||||
"select cos(c8) from ct4",
|
f"select cos(c8) from {dbname}.ct4",
|
||||||
"select cos(c9) from ct4",
|
f"select cos(c9) from {dbname}.ct4",
|
||||||
"select cos(ts) from stb1" ,
|
f"select cos(ts) from {dbname}.stb1" ,
|
||||||
"select cos(c7) from stb1",
|
f"select cos(c7) from {dbname}.stb1",
|
||||||
"select cos(c8) from stb1",
|
f"select cos(c8) from {dbname}.stb1",
|
||||||
"select cos(c9) from stb1" ,
|
f"select cos(c9) from {dbname}.stb1" ,
|
||||||
|
|
||||||
"select cos(ts) from stbbb1" ,
|
f"select cos(ts) from {dbname}.stbbb1" ,
|
||||||
"select cos(c7) from stbbb1",
|
f"select cos(c7) from {dbname}.stbbb1",
|
||||||
|
|
||||||
"select cos(ts) from tbname",
|
f"select cos(ts) from {dbname}.tbname",
|
||||||
"select cos(c9) from tbname"
|
f"select cos(c9) from {dbname}.tbname"
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -169,103 +174,103 @@ class TDTestCase:
|
||||||
|
|
||||||
|
|
||||||
type_sql_lists = [
|
type_sql_lists = [
|
||||||
"select cos(c1) from t1",
|
f"select cos(c1) from {dbname}.t1",
|
||||||
"select cos(c2) from t1",
|
f"select cos(c2) from {dbname}.t1",
|
||||||
"select cos(c3) from t1",
|
f"select cos(c3) from {dbname}.t1",
|
||||||
"select cos(c4) from t1",
|
f"select cos(c4) from {dbname}.t1",
|
||||||
"select cos(c5) from t1",
|
f"select cos(c5) from {dbname}.t1",
|
||||||
"select cos(c6) from t1",
|
f"select cos(c6) from {dbname}.t1",
|
||||||
|
|
||||||
"select cos(c1) from ct1",
|
f"select cos(c1) from {dbname}.ct1",
|
||||||
"select cos(c2) from ct1",
|
f"select cos(c2) from {dbname}.ct1",
|
||||||
"select cos(c3) from ct1",
|
f"select cos(c3) from {dbname}.ct1",
|
||||||
"select cos(c4) from ct1",
|
f"select cos(c4) from {dbname}.ct1",
|
||||||
"select cos(c5) from ct1",
|
f"select cos(c5) from {dbname}.ct1",
|
||||||
"select cos(c6) from ct1",
|
f"select cos(c6) from {dbname}.ct1",
|
||||||
|
|
||||||
"select cos(c1) from ct3",
|
f"select cos(c1) from {dbname}.ct3",
|
||||||
"select cos(c2) from ct3",
|
f"select cos(c2) from {dbname}.ct3",
|
||||||
"select cos(c3) from ct3",
|
f"select cos(c3) from {dbname}.ct3",
|
||||||
"select cos(c4) from ct3",
|
f"select cos(c4) from {dbname}.ct3",
|
||||||
"select cos(c5) from ct3",
|
f"select cos(c5) from {dbname}.ct3",
|
||||||
"select cos(c6) from ct3",
|
f"select cos(c6) from {dbname}.ct3",
|
||||||
|
|
||||||
"select cos(c1) from stb1",
|
f"select cos(c1) from {dbname}.stb1",
|
||||||
"select cos(c2) from stb1",
|
f"select cos(c2) from {dbname}.stb1",
|
||||||
"select cos(c3) from stb1",
|
f"select cos(c3) from {dbname}.stb1",
|
||||||
"select cos(c4) from stb1",
|
f"select cos(c4) from {dbname}.stb1",
|
||||||
"select cos(c5) from stb1",
|
f"select cos(c5) from {dbname}.stb1",
|
||||||
"select cos(c6) from stb1",
|
f"select cos(c6) from {dbname}.stb1",
|
||||||
|
|
||||||
"select cos(c6) as alisb from stb1",
|
f"select cos(c6) as alisb from {dbname}.stb1",
|
||||||
"select cos(c6) alisb from stb1",
|
f"select cos(c6) alisb from {dbname}.stb1",
|
||||||
]
|
]
|
||||||
|
|
||||||
for type_sql in type_sql_lists:
|
for type_sql in type_sql_lists:
|
||||||
tdSql.query(type_sql)
|
tdSql.query(type_sql)
|
||||||
|
|
||||||
def basic_cosin_function(self):
|
def basic_cos_function(self, dbname="db"):
|
||||||
|
|
||||||
# basic query
|
# basic query
|
||||||
tdSql.query("select c1 from ct3")
|
tdSql.query(f"select c1 from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select c1 from t1")
|
tdSql.query(f"select c1 from {dbname}.t1")
|
||||||
tdSql.checkRows(12)
|
tdSql.checkRows(12)
|
||||||
tdSql.query("select c1 from stb1")
|
tdSql.query(f"select c1 from {dbname}.stb1")
|
||||||
tdSql.checkRows(25)
|
tdSql.checkRows(25)
|
||||||
|
|
||||||
# used for empty table , ct3 is empty
|
# used for empty table , ct3 is empty
|
||||||
tdSql.query("select cos(c1) from ct3")
|
tdSql.query(f"select cos(c1) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select cos(c2) from ct3")
|
tdSql.query(f"select cos(c2) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select cos(c3) from ct3")
|
tdSql.query(f"select cos(c3) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select cos(c4) from ct3")
|
tdSql.query(f"select cos(c4) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select cos(c5) from ct3")
|
tdSql.query(f"select cos(c5) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
tdSql.query("select cos(c6) from ct3")
|
tdSql.query(f"select cos(c6) from {dbname}.ct3")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
|
||||||
# # used for regular table
|
# # used for regular table
|
||||||
tdSql.query("select cos(c1) from t1")
|
tdSql.query(f"select cos(c1) from {dbname}.t1")
|
||||||
tdSql.checkData(0, 0, None)
|
tdSql.checkData(0, 0, None)
|
||||||
tdSql.checkData(1 , 0, 0.540302306)
|
tdSql.checkData(1 , 0, 0.540302306)
|
||||||
tdSql.checkData(3 , 0, -0.989992497)
|
tdSql.checkData(3 , 0, -0.989992497)
|
||||||
tdSql.checkData(5 , 0, None)
|
tdSql.checkData(5 , 0, None)
|
||||||
|
|
||||||
tdSql.query("select c1, c2, c3 , c4, c5 from t1")
|
tdSql.query(f"select c1, c2, c3 , c4, c5 from {dbname}.t1")
|
||||||
tdSql.checkData(1, 4, 1.11000)
|
tdSql.checkData(1, 4, 1.11000)
|
||||||
tdSql.checkData(3, 3, 33)
|
tdSql.checkData(3, 3, 33)
|
||||||
tdSql.checkData(5, 4, None)
|
tdSql.checkData(5, 4, None)
|
||||||
|
|
||||||
tdSql.query("select ts,c1, c2, c3 , c4, c5 from t1")
|
tdSql.query(f"select ts,c1, c2, c3 , c4, c5 from {dbname}.t1")
|
||||||
tdSql.checkData(1, 5, 1.11000)
|
tdSql.checkData(1, 5, 1.11000)
|
||||||
tdSql.checkData(3, 4, 33)
|
tdSql.checkData(3, 4, 33)
|
||||||
tdSql.checkData(5, 5, None)
|
tdSql.checkData(5, 5, None)
|
||||||
|
|
||||||
self.check_result_auto_cos( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from t1", "select cos(abs(c1)), cos(abs(c2)) ,cos(abs(c3)), cos(abs(c4)), cos(abs(c5)) from t1")
|
self.check_result_auto_cos( f"select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from {dbname}.t1", f"select cos(abs(c1)), cos(abs(c2)) ,cos(abs(c3)), cos(abs(c4)), cos(abs(c5)) from {dbname}.t1")
|
||||||
|
|
||||||
# used for sub table
|
# used for sub table
|
||||||
tdSql.query("select c2 ,cos(c2) from ct1")
|
tdSql.query(f"select c2 ,cos(c2) from {dbname}.ct1")
|
||||||
tdSql.checkData(0, 1, 0.975339851)
|
tdSql.checkData(0, 1, 0.975339851)
|
||||||
tdSql.checkData(1 , 1, -0.830564903)
|
tdSql.checkData(1 , 1, -0.830564903)
|
||||||
tdSql.checkData(3 , 1, 0.602244939)
|
tdSql.checkData(3 , 1, 0.602244939)
|
||||||
tdSql.checkData(4 , 1, 1.000000000)
|
tdSql.checkData(4 , 1, 1.000000000)
|
||||||
|
|
||||||
tdSql.query("select c1, c5 ,cos(c5) from ct4")
|
tdSql.query(f"select c1, c5 ,cos(c5) from {dbname}.ct4")
|
||||||
tdSql.checkData(0 , 2, None)
|
tdSql.checkData(0 , 2, None)
|
||||||
tdSql.checkData(1 , 2, -0.855242438)
|
tdSql.checkData(1 , 2, -0.855242438)
|
||||||
tdSql.checkData(2 , 2, 0.083882969)
|
tdSql.checkData(2 , 2, 0.083882969)
|
||||||
tdSql.checkData(3 , 2, 0.929841474)
|
tdSql.checkData(3 , 2, 0.929841474)
|
||||||
tdSql.checkData(5 , 2, None)
|
tdSql.checkData(5 , 2, None)
|
||||||
|
|
||||||
self.check_result_auto_cos( "select c1, c2, c3 , c4, c5 from ct1", "select cos(c1), cos(c2) ,cos(c3), cos(c4), cos(c5) from ct1")
|
self.check_result_auto_cos( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select cos(c1), cos(c2) ,cos(c3), cos(c4), cos(c5) from {dbname}.ct1")
|
||||||
|
|
||||||
# nest query for cos functions
|
# nest query for cos functions
|
||||||
tdSql.query("select c4 , cos(c4) ,cos(cos(c4)) , cos(cos(cos(c4))) from ct1;")
|
tdSql.query(f"select c4 , cos(c4) ,cos(cos(c4)) , cos(cos(cos(c4))) from {dbname}.ct1;")
|
||||||
tdSql.checkData(0 , 0 , 88)
|
tdSql.checkData(0 , 0 , 88)
|
||||||
tdSql.checkData(0 , 1 , 0.999373284)
|
tdSql.checkData(0 , 1 , 0.999373284)
|
||||||
tdSql.checkData(0 , 2 , 0.540829563)
|
tdSql.checkData(0 , 2 , 0.540829563)
|
||||||
|
@ -283,22 +288,22 @@ class TDTestCase:
|
||||||
|
|
||||||
# used for stable table
|
# used for stable table
|
||||||
|
|
||||||
tdSql.query("select cos(c1) from stb1")
|
tdSql.query(f"select cos(c1) from {dbname}.stb1")
|
||||||
tdSql.checkRows(25)
|
tdSql.checkRows(25)
|
||||||
|
|
||||||
|
|
||||||
# used for not exists table
|
# used for not exists table
|
||||||
tdSql.error("select cos(c1) from stbbb1")
|
tdSql.error(f"select cos(c1) from {dbname}.stbbb1")
|
||||||
tdSql.error("select cos(c1) from tbname")
|
tdSql.error(f"select cos(c1) from {dbname}.tbname")
|
||||||
tdSql.error("select cos(c1) from ct5")
|
tdSql.error(f"select cos(c1) from {dbname}.ct5")
|
||||||
|
|
||||||
# mix with common col
|
# mix with common col
|
||||||
tdSql.query("select c1, cos(c1) from ct1")
|
tdSql.query(f"select c1, cos(c1) from {dbname}.ct1")
|
||||||
tdSql.query("select c2, cos(c2) from ct4")
|
tdSql.query(f"select c2, cos(c2) from {dbname}.ct4")
|
||||||
|
|
||||||
|
|
||||||
# mix with common functions
|
# mix with common functions
|
||||||
tdSql.query("select c1, cos(c1),cos(c1), cos(cos(c1)) from ct4 ")
|
tdSql.query(f"select c1, cos(c1),cos(c1), cos(cos(c1)) from {dbname}.ct4 ")
|
||||||
tdSql.checkData(0 , 0 ,None)
|
tdSql.checkData(0 , 0 ,None)
|
||||||
tdSql.checkData(0 , 1 ,None)
|
tdSql.checkData(0 , 1 ,None)
|
||||||
tdSql.checkData(0 , 2 ,None)
|
tdSql.checkData(0 , 2 ,None)
|
||||||
|
@ -309,24 +314,24 @@ class TDTestCase:
|
||||||
tdSql.checkData(3 , 2 ,0.960170287)
|
tdSql.checkData(3 , 2 ,0.960170287)
|
||||||
tdSql.checkData(3 , 3 ,0.573380480)
|
tdSql.checkData(3 , 3 ,0.573380480)
|
||||||
|
|
||||||
tdSql.query("select c1, cos(c1),c5, floor(c5) from stb1 ")
|
tdSql.query(f"select c1, cos(c1),c5, floor(c5) from {dbname}.stb1 ")
|
||||||
|
|
||||||
# # mix with agg functions , not support
|
# # mix with agg functions , not support
|
||||||
tdSql.error("select c1, cos(c1),c5, count(c5) from stb1 ")
|
tdSql.error(f"select c1, cos(c1),c5, count(c5) from {dbname}.stb1 ")
|
||||||
tdSql.error("select c1, cos(c1),c5, count(c5) from ct1 ")
|
tdSql.error(f"select c1, cos(c1),c5, count(c5) from {dbname}.ct1 ")
|
||||||
tdSql.error("select cos(c1), count(c5) from stb1 ")
|
tdSql.error(f"select cos(c1), count(c5) from {dbname}.stb1 ")
|
||||||
tdSql.error("select cos(c1), count(c5) from ct1 ")
|
tdSql.error(f"select cos(c1), count(c5) from {dbname}.ct1 ")
|
||||||
tdSql.error("select c1, count(c5) from ct1 ")
|
tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ")
|
||||||
tdSql.error("select c1, count(c5) from stb1 ")
|
tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ")
|
||||||
|
|
||||||
# agg functions mix with agg functions
|
# agg functions mix with agg functions
|
||||||
|
|
||||||
tdSql.query("select max(c5), count(c5) from stb1")
|
tdSql.query(f"select max(c5), count(c5) from {dbname}.stb1")
|
||||||
tdSql.query("select max(c5), count(c5) from ct1")
|
tdSql.query(f"select max(c5), count(c5) from {dbname}.ct1")
|
||||||
|
|
||||||
|
|
||||||
# # bug fix for compute
|
# # bug fix for compute
|
||||||
tdSql.query("select c1, cos(c1) -0 ,cos(c1-4)-0 from ct4 ")
|
tdSql.query(f"select c1, cos(c1) -0 ,cos(c1-4)-0 from {dbname}.ct4 ")
|
||||||
tdSql.checkData(0, 0, None)
|
tdSql.checkData(0, 0, None)
|
||||||
tdSql.checkData(0, 1, None)
|
tdSql.checkData(0, 1, None)
|
||||||
tdSql.checkData(0, 2, None)
|
tdSql.checkData(0, 2, None)
|
||||||
|
@ -334,43 +339,42 @@ class TDTestCase:
|
||||||
tdSql.checkData(1, 1, -0.145500034)
|
tdSql.checkData(1, 1, -0.145500034)
|
||||||
tdSql.checkData(1, 2, -0.653643621)
|
tdSql.checkData(1, 2, -0.653643621)
|
||||||
|
|
||||||
tdSql.query(" select c1, cos(c1) -0 ,cos(c1-0.1)-0.1 from ct4")
|
tdSql.query(f" select c1, cos(c1) -0 ,cos(c1-0.1)-0.1 from {dbname}.ct4")
|
||||||
tdSql.checkData(0, 0, None)
|
tdSql.checkData(0, 0, None)
|
||||||
tdSql.checkData(0, 1, None)
|
tdSql.checkData(0, 1, None)
|
||||||
tdSql.checkData(0, 2, None)
|
tdSql.checkData(0, 2, None)
|
||||||
tdSql.checkData(1, 0, 8)
|
tdSql.checkData(1, 0, 8)
|
||||||
tdSql.checkData(1, 1, -0.145500034)
|
tdSql.checkData(1, 1, -0.145500034)
|
||||||
tdSql.checkData(1, 2, -0.146002126)
|
tdSql.checkData(1, 2, -0.146002126)
|
||||||
|
tdSql.query(f"select c1, cos(c1), c2, cos(c2), c3, cos(c3) from {dbname}.ct1")
|
||||||
|
|
||||||
tdSql.query("select c1, cos(c1), c2, cos(c2), c3, cos(c3) from ct1")
|
|
||||||
|
|
||||||
def test_big_number(self):
|
def test_big_number(self, dbname="db"):
|
||||||
|
|
||||||
tdSql.query("select c1, cos(100000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, cos(100000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
tdSql.checkData(4, 1, math.cos(100000000))
|
tdSql.checkData(4, 1, math.cos(100000000))
|
||||||
|
|
||||||
|
tdSql.query(f"select c1, cos(10000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
tdSql.query("select c1, cos(10000000000000) from ct1") # bigint to double data overflow
|
|
||||||
tdSql.checkData(4, 1, math.cos(10000000000000))
|
tdSql.checkData(4, 1, math.cos(10000000000000))
|
||||||
|
|
||||||
tdSql.query("select c1, cos(10000000000000000000000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, cos(10000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
tdSql.query("select c1, cos(10000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value
|
tdSql.query(f"select c1, cos(10000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value
|
||||||
tdSql.checkData(1, 1, math.cos(10000000000000000000000000.0))
|
tdSql.checkData(1, 1, math.cos(10000000000000000000000000.0))
|
||||||
|
|
||||||
tdSql.query("select c1, cos(10000000000000000000000000000000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, cos(10000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
tdSql.query("select c1, cos(10000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value
|
tdSql.query(f"select c1, cos(10000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value
|
||||||
tdSql.checkData(4, 1, math.cos(10000000000000000000000000000000000.0))
|
tdSql.checkData(4, 1, math.cos(10000000000000000000000000000000000.0))
|
||||||
|
|
||||||
tdSql.query("select c1, cos(10000000000000000000000000000000000000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, cos(10000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
tdSql.query("select c1, cos(10000000000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value
|
tdSql.query(f"select c1, cos(10000000000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value
|
||||||
|
|
||||||
tdSql.checkData(4, 1, math.cos(10000000000000000000000000000000000000000.0))
|
tdSql.checkData(4, 1, math.cos(10000000000000000000000000000000000000000.0))
|
||||||
|
|
||||||
tdSql.query("select c1, cos(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from ct1") # bigint to double data overflow
|
tdSql.query(f"select c1, cos(10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||||
|
|
||||||
def abs_func_filter(self):
|
def abs_func_filter(self, dbname="db"):
|
||||||
tdSql.execute("use db")
|
tdSql.execute(f"use {dbname}")
|
||||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(cos(c1)-0.5) from ct4 where c1>5 ")
|
tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(cos(c1)-0.5) from {dbname}.ct4 where c1>5 ")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
tdSql.checkData(0,0,8)
|
tdSql.checkData(0,0,8)
|
||||||
tdSql.checkData(0,1,8.000000000)
|
tdSql.checkData(0,1,8.000000000)
|
||||||
|
@ -378,7 +382,7 @@ class TDTestCase:
|
||||||
tdSql.checkData(0,3,7.900000000)
|
tdSql.checkData(0,3,7.900000000)
|
||||||
tdSql.checkData(0,4,0.000000000)
|
tdSql.checkData(0,4,0.000000000)
|
||||||
|
|
||||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(cos(c1)-0.5) from ct4 where c1=5 ")
|
tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(cos(c1)-0.5) from {dbname}.ct4 where c1=5 ")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,5)
|
tdSql.checkData(0,0,5)
|
||||||
tdSql.checkData(0,1,5.000000000)
|
tdSql.checkData(0,1,5.000000000)
|
||||||
|
@ -386,7 +390,7 @@ class TDTestCase:
|
||||||
tdSql.checkData(0,3,4.900000000)
|
tdSql.checkData(0,3,4.900000000)
|
||||||
tdSql.checkData(0,4,0.000000000)
|
tdSql.checkData(0,4,0.000000000)
|
||||||
|
|
||||||
tdSql.query("select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(cos(c1)-0.5) from ct4 where c1>cos(c1) limit 1 ")
|
tdSql.query(f"select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(cos(c1)-0.5) from {dbname}.ct4 where c1>cos(c1) limit 1 ")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,8)
|
tdSql.checkData(0,0,8)
|
||||||
tdSql.checkData(0,1,88888)
|
tdSql.checkData(0,1,88888)
|
||||||
|
@ -395,44 +399,38 @@ class TDTestCase:
|
||||||
tdSql.checkData(0,4,7.900000000)
|
tdSql.checkData(0,4,7.900000000)
|
||||||
tdSql.checkData(0,5,0.000000000)
|
tdSql.checkData(0,5,0.000000000)
|
||||||
|
|
||||||
def pow_Arithmetic(self):
|
def check_boundary_values(self, dbname="bound_test"):
|
||||||
pass
|
|
||||||
|
|
||||||
def check_boundary_values(self):
|
|
||||||
|
|
||||||
PI=3.1415926
|
PI=3.1415926
|
||||||
|
|
||||||
tdSql.execute("drop database if exists bound_test")
|
tdSql.execute(f"drop database if exists {dbname}")
|
||||||
tdSql.execute("create database if not exists bound_test")
|
tdSql.execute(f"create database if not exists {dbname}")
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
tdSql.execute("use bound_test")
|
tdSql.execute(f"use {dbname}")
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
"create table stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);"
|
f"create table {dbname}.stb_bound (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(32),c9 nchar(32), c10 timestamp) tags (t1 int);"
|
||||||
)
|
)
|
||||||
tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )')
|
tdSql.execute(f'create table {dbname}.sub1_bound using {dbname}.stb_bound tags ( 1 )')
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
f"insert into {dbname}.sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
f"insert into {dbname}.sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
f"insert into {dbname}.sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
f"insert into {dbname}.sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||||
)
|
)
|
||||||
tdSql.error(
|
# self.check_result_auto_cos( f"select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from {dbname}.sub1_bound ", f"select cos(abs(c1)), cos(abs(c2)) ,cos(abs(c3)), cos(abs(c4)), cos(abs(c5)) from {dbname}.sub1_bound")
|
||||||
f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
|
||||||
)
|
|
||||||
self.check_result_auto_cos( "select abs(c1), abs(c2), abs(c3) , abs(c4), abs(c5) from sub1_bound ", "select cos(abs(c1)), cos(abs(c2)) ,cos(abs(c3)), cos(abs(c4)), cos(abs(c5)) from sub1_bound")
|
|
||||||
|
|
||||||
self.check_result_auto_cos( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select cos(c1), cos(c2) ,cos(c3), cos(c3), cos(c2) ,cos(c1) from sub1_bound")
|
self.check_result_auto_cos( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select cos(c1), cos(c2) ,cos(c3), cos(c3), cos(c2) ,cos(c1) from {dbname}.sub1_bound")
|
||||||
|
|
||||||
self.check_result_auto_cos("select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from sub1_bound" , "select cos(abs(c1)) from sub1_bound" )
|
self.check_result_auto_cos(f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from {dbname}.sub1_bound" , f"select cos(abs(c1)) from {dbname}.sub1_bound" )
|
||||||
|
|
||||||
# check basic elem for table per row
|
# check basic elem for table per row
|
||||||
tdSql.query("select cos(abs(c1)) ,cos(abs(c2)) , cos(abs(c3)) , cos(abs(c4)), cos(abs(c5)), cos(abs(c6)) from sub1_bound ")
|
tdSql.query(f"select cos(abs(c1)) ,cos(abs(c2)) , cos(abs(c3)) , cos(abs(c4)), cos(abs(c5)), cos(abs(c6)) from {dbname}.sub1_bound ")
|
||||||
tdSql.checkData(0,0,math.cos(2147483647))
|
tdSql.checkData(0,0,math.cos(2147483647))
|
||||||
tdSql.checkData(0,1,math.cos(9223372036854775807))
|
tdSql.checkData(0,1,math.cos(9223372036854775807))
|
||||||
tdSql.checkData(0,2,math.cos(32767))
|
tdSql.checkData(0,2,math.cos(32767))
|
||||||
|
@ -450,45 +448,44 @@ class TDTestCase:
|
||||||
tdSql.checkData(3,4,math.cos(339999995214436424907732413799364296704.00000))
|
tdSql.checkData(3,4,math.cos(339999995214436424907732413799364296704.00000))
|
||||||
|
|
||||||
# check + - * / in functions
|
# check + - * / in functions
|
||||||
tdSql.query("select cos(abs(c1+1)) ,cos(abs(c2)) , cos(abs(c3*1)) , cos(abs(c4/2)), cos(abs(c5))/2, cos(abs(c6)) from sub1_bound ")
|
tdSql.query(f"select cos(abs(c1+1)) ,cos(abs(c2)) , cos(abs(c3*1)) , cos(abs(c4/2)), cos(abs(c5))/2, cos(abs(c6)) from {dbname}.sub1_bound ")
|
||||||
tdSql.checkData(0,0,math.cos(2147483648.000000000))
|
tdSql.checkData(0,0,math.cos(2147483648.000000000))
|
||||||
tdSql.checkData(0,1,math.cos(9223372036854775807))
|
tdSql.checkData(0,1,math.cos(9223372036854775807))
|
||||||
tdSql.checkData(0,2,math.cos(32767.000000000))
|
tdSql.checkData(0,2,math.cos(32767.000000000))
|
||||||
tdSql.checkData(0,3,math.cos(63.500000000))
|
tdSql.checkData(0,3,math.cos(63.500000000))
|
||||||
|
|
||||||
tdSql.execute("create stable st (ts timestamp, num1 float, num2 double) tags (t1 int);")
|
tdSql.execute(f"create stable {dbname}.st (ts timestamp, num1 float, num2 double) tags (t1 int);")
|
||||||
tdSql.execute(f'create table tb1 using st tags (1)')
|
tdSql.execute(f'create table {dbname}.tb1 using {dbname}.st tags (1)')
|
||||||
tdSql.execute(f'create table tb2 using st tags (2)')
|
tdSql.execute(f'create table {dbname}.tb2 using {dbname}.st tags (2)')
|
||||||
tdSql.execute(f'create table tb3 using st tags (3)')
|
tdSql.execute(f'create table {dbname}.tb3 using {dbname}.st tags (3)')
|
||||||
tdSql.execute('insert into tb1 values (now()-40s, {}, {})'.format(PI/2 ,PI/2 ))
|
tdSql.execute(f'insert into {dbname}.tb1 values (now()-40s, {PI/2}, {PI/2})')
|
||||||
tdSql.execute('insert into tb1 values (now()-30s, {}, {})'.format(PI ,PI ))
|
tdSql.execute(f'insert into {dbname}.tb1 values (now()-30s, {PI}, {PI})')
|
||||||
tdSql.execute('insert into tb1 values (now()-20s, {}, {})'.format(PI*1.5 ,PI*1.5))
|
tdSql.execute(f'insert into {dbname}.tb1 values (now()-20s, {PI*1.5}, {PI*1.5})')
|
||||||
tdSql.execute('insert into tb1 values (now()-10s, {}, {})'.format(PI*2 ,PI*2))
|
tdSql.execute(f'insert into {dbname}.tb1 values (now()-10s, {PI*2}, {PI*2})')
|
||||||
tdSql.execute('insert into tb1 values (now(), {}, {})'.format(PI*2.5 ,PI*2.5))
|
tdSql.execute(f'insert into {dbname}.tb1 values (now(), {PI*2.5}, {PI*2.5})')
|
||||||
|
|
||||||
tdSql.execute('insert into tb2 values (now()-40s, {}, {})'.format(PI/2 ,PI/2 ))
|
tdSql.execute(f'insert into {dbname}.tb2 values (now()-40s, {PI/2}, {PI/2})')
|
||||||
tdSql.execute('insert into tb2 values (now()-30s, {}, {})'.format(PI ,PI ))
|
tdSql.execute(f'insert into {dbname}.tb2 values (now()-30s, {PI}, {PI})')
|
||||||
tdSql.execute('insert into tb2 values (now()-20s, {}, {})'.format(PI*1.5 ,PI*1.5))
|
tdSql.execute(f'insert into {dbname}.tb2 values (now()-20s, {PI*1.5}, {PI*1.5})')
|
||||||
tdSql.execute('insert into tb2 values (now()-10s, {}, {})'.format(PI*2 ,PI*2))
|
tdSql.execute(f'insert into {dbname}.tb2 values (now()-10s, {PI*2}, {PI*2})')
|
||||||
tdSql.execute('insert into tb2 values (now(), {}, {})'.format(PI*2.5 ,PI*2.5))
|
tdSql.execute(f'insert into {dbname}.tb2 values (now(), {PI*2.5}, {PI*2.5})')
|
||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
tdSql.execute('insert into tb3 values (now()+{}s, {}, {})'.format(i,PI*(5+i)/2 ,PI*(5+i)/2))
|
tdSql.execute(f'insert into {dbname}.tb3 values (now()+{i}s, {PI*(5+i)/2}, {PI*(5+i)/2})')
|
||||||
|
|
||||||
self.check_result_auto_cos("select num1,num2 from tb3;" , "select cos(num1),cos(num2) from tb3")
|
# self.check_result_auto_cos(f"select num1,num2 from {dbname}.tb3;" , f"select cos(num1),cos(num2) from {dbname}.tb3")
|
||||||
|
|
||||||
def support_super_table_test(self):
|
def support_super_table_test(self, dbname="db"):
|
||||||
tdSql.execute(" use db ")
|
tdSql.execute(f" use {dbname} ")
|
||||||
self.check_result_auto_cos( " select c5 from stb1 order by ts " , "select cos(c5) from stb1 order by ts" )
|
self.check_result_auto_cos( f" select c5 from {dbname}.stb1 order by ts " , f"select cos(c5) from {dbname}.stb1 order by ts" )
|
||||||
self.check_result_auto_cos( " select c5 from stb1 order by tbname " , "select cos(c5) from stb1 order by tbname" )
|
self.check_result_auto_cos( f" select c5 from {dbname}.stb1 order by tbname " , f"select cos(c5) from {dbname}.stb1 order by tbname" )
|
||||||
self.check_result_auto_cos( " select c5 from stb1 where c1 > 0 order by tbname " , "select cos(c5) from stb1 where c1 > 0 order by tbname" )
|
self.check_result_auto_cos( f" select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select cos(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||||
self.check_result_auto_cos( " select c5 from stb1 where c1 > 0 order by tbname " , "select cos(c5) from stb1 where c1 > 0 order by tbname" )
|
self.check_result_auto_cos( f" select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select cos(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||||
|
|
||||||
self.check_result_auto_cos( " select t1,c5 from stb1 order by ts " , "select cos(t1), cos(c5) from stb1 order by ts" )
|
self.check_result_auto_cos( f" select t1,c5 from {dbname}.stb1 order by ts " , f"select cos(t1), cos(c5) from {dbname}.stb1 order by ts" )
|
||||||
self.check_result_auto_cos( " select t1,c5 from stb1 order by tbname " , "select cos(t1) ,cos(c5) from stb1 order by tbname" )
|
self.check_result_auto_cos( f" select t1,c5 from {dbname}.stb1 order by tbname " , f"select cos(t1) ,cos(c5) from {dbname}.stb1 order by tbname" )
|
||||||
self.check_result_auto_cos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select cos(t1) ,cos(c5) from stb1 where c1 > 0 order by tbname" )
|
self.check_result_auto_cos( f" select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select cos(t1) ,cos(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||||
self.check_result_auto_cos( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select cos(t1) , cos(c5) from stb1 where c1 > 0 order by tbname" )
|
self.check_result_auto_cos( f" select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select cos(t1) , cos(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||||
pass
|
|
||||||
|
|
||||||
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
@ -507,7 +504,7 @@ class TDTestCase:
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step4: cos basic query ============")
|
tdLog.printNoPrefix("==========step4: cos basic query ============")
|
||||||
|
|
||||||
self.basic_cosin_function()
|
self.basic_cos_function()
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step5: big number cos query ============")
|
tdLog.printNoPrefix("==========step5: big number cos query ============")
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,14 @@ from util.sqlset import *
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
def init(self, conn, logSql):
|
def init(self, conn, logSql):
|
||||||
tdLog.debug("start to execute %s" % __file__)
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
tdSql.init(conn.cursor(),logSql)
|
tdSql.init(conn.cursor(),False)
|
||||||
self.setsql = TDSetSql()
|
self.setsql = TDSetSql()
|
||||||
self.rowNum = 10
|
self.rowNum = 10
|
||||||
self.ts = 1537146000000
|
self.ts = 1537146000000
|
||||||
|
|
||||||
self.ntbname = 'ntb'
|
dbname = "db"
|
||||||
self.stbname = 'stb'
|
self.ntbname = f'{dbname}.ntb'
|
||||||
|
self.stbname = f'{dbname}.stb'
|
||||||
self.column_dict = {
|
self.column_dict = {
|
||||||
'ts':'timestamp',
|
'ts':'timestamp',
|
||||||
'c1':'int',
|
'c1':'int',
|
||||||
|
|
|
@ -11,17 +11,17 @@ class TDTestCase:
|
||||||
self.row_nums = 10
|
self.row_nums = 10
|
||||||
self.tb_nums = 10
|
self.tb_nums = 10
|
||||||
self.ts = 1537146000000
|
self.ts = 1537146000000
|
||||||
|
|
||||||
def prepare_datas(self, stb_name , tb_nums , row_nums ):
|
def prepare_datas(self, stb_name , tb_nums , row_nums, dbname="db" ):
|
||||||
tdSql.execute(" use db ")
|
tdSql.execute(f" use {dbname} ")
|
||||||
tdSql.execute(f" create stable {stb_name} (ts timestamp , c1 int , c2 bigint , c3 float , c4 double , c5 smallint , c6 tinyint , c7 bool , c8 binary(36) , c9 nchar(36) , uc1 int unsigned,\
|
tdSql.execute(f" create stable {dbname}.{stb_name} (ts timestamp , c1 int , c2 bigint , c3 float , c4 double , c5 smallint , c6 tinyint , c7 bool , c8 binary(36) , c9 nchar(36) , uc1 int unsigned,\
|
||||||
uc2 bigint unsigned ,uc3 smallint unsigned , uc4 tinyint unsigned ) tags(t1 timestamp , t2 int , t3 bigint , t4 float , t5 double , t6 smallint , t7 tinyint , t8 bool , t9 binary(36)\
|
uc2 bigint unsigned ,uc3 smallint unsigned , uc4 tinyint unsigned ) tags(t1 timestamp , t2 int , t3 bigint , t4 float , t5 double , t6 smallint , t7 tinyint , t8 bool , t9 binary(36)\
|
||||||
, t10 nchar(36) , t11 int unsigned , t12 bigint unsigned ,t13 smallint unsigned , t14 tinyint unsigned ) ")
|
, t10 nchar(36) , t11 int unsigned , t12 bigint unsigned ,t13 smallint unsigned , t14 tinyint unsigned ) ")
|
||||||
|
|
||||||
for i in range(tb_nums):
|
for i in range(tb_nums):
|
||||||
tbname = f"sub_{stb_name}_{i}"
|
tbname = f"{dbname}.sub_{stb_name}_{i}"
|
||||||
ts = self.ts + i*10000
|
ts = self.ts + i*10000
|
||||||
tdSql.execute(f"create table {tbname} using {stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )")
|
tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )")
|
||||||
|
|
||||||
for row in range(row_nums):
|
for row in range(row_nums):
|
||||||
ts = self.ts + row*1000
|
ts = self.ts + row*1000
|
||||||
|
@ -30,143 +30,144 @@ class TDTestCase:
|
||||||
for null in range(5):
|
for null in range(5):
|
||||||
ts = self.ts + row_nums*1000 + null*1000
|
ts = self.ts + row_nums*1000 + null*1000
|
||||||
tdSql.execute(f"insert into {tbname} values({ts} , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL )")
|
tdSql.execute(f"insert into {tbname} values({ts} , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL )")
|
||||||
|
|
||||||
def basic_query(self):
|
def basic_query(self, dbname="db"):
|
||||||
tdSql.query("select count(*) from stb")
|
tdSql.query(f"select count(*) from {dbname}.stb")
|
||||||
tdSql.checkData(0,0,(self.row_nums + 5 )*self.tb_nums)
|
tdSql.checkData(0,0,(self.row_nums + 5 )*self.tb_nums)
|
||||||
tdSql.query("select count(c1) from stb")
|
tdSql.query(f"select count(c1) from {dbname}.stb")
|
||||||
tdSql.checkData(0,0,(self.row_nums )*self.tb_nums)
|
tdSql.checkData(0,0,(self.row_nums )*self.tb_nums)
|
||||||
tdSql.query(" select tbname , count(*) from stb partition by tbname ")
|
tdSql.query(f"select tbname , count(*) from {dbname}.stb partition by tbname ")
|
||||||
tdSql.checkRows(self.tb_nums)
|
tdSql.checkRows(self.tb_nums)
|
||||||
tdSql.query(" select count(c1) from stb group by t1 order by t1 ")
|
tdSql.query(f"select count(c1) from {dbname}.stb group by t1 order by t1 ")
|
||||||
tdSql.checkRows(self.tb_nums)
|
tdSql.checkRows(self.tb_nums)
|
||||||
tdSql.error(" select count(c1) from stb group by c1 order by t1 ")
|
tdSql.error(f"select count(c1) from {dbname}.stb group by c1 order by t1 ")
|
||||||
tdSql.error(" select count(t1) from stb group by c1 order by t1 ")
|
tdSql.error(f"select count(t1) from {dbname}.stb group by c1 order by t1 ")
|
||||||
tdSql.query(" select count(c1) from stb group by tbname order by tbname ")
|
tdSql.query(f"select count(c1) from {dbname}.stb group by tbname order by tbname ")
|
||||||
tdSql.checkRows(self.tb_nums)
|
tdSql.checkRows(self.tb_nums)
|
||||||
# bug need fix
|
# bug need fix
|
||||||
# tdSql.query(" select count(t1) from stb group by t2 order by t2 ")
|
# tdSql.query(f"select count(t1) from {dbname}.stb group by t2 order by t2 ")
|
||||||
# tdSql.checkRows(self.tb_nums)
|
# tdSql.checkRows(self.tb_nums)
|
||||||
tdSql.query(" select count(c1) from stb group by c1 order by c1 ")
|
tdSql.query(f"select count(c1) from {dbname}.stb group by c1 order by c1 ")
|
||||||
tdSql.checkRows(self.row_nums+1)
|
tdSql.checkRows(self.row_nums+1)
|
||||||
|
|
||||||
tdSql.query(" select c1 , count(c1) from stb group by c1 order by c1 ")
|
tdSql.query(f"select c1 , count(c1) from {dbname}.stb group by c1 order by c1 ")
|
||||||
tdSql.checkRows(self.row_nums+1)
|
tdSql.checkRows(self.row_nums+1)
|
||||||
|
|
||||||
tdSql.query("select count(c1) from stb group by abs(c1) order by abs(c1)")
|
tdSql.query(f"select count(c1) from {dbname}.stb group by abs(c1) order by abs(c1)")
|
||||||
tdSql.checkRows(self.row_nums+1)
|
tdSql.checkRows(self.row_nums+1)
|
||||||
tdSql.query("select abs(c1+c3), count(c1+c3) from stb group by abs(c1+c3) order by abs(c1+c3)")
|
tdSql.query(f"select abs(c1+c3), count(c1+c3) from {dbname}.stb group by abs(c1+c3) order by abs(c1+c3)")
|
||||||
tdSql.checkRows(self.row_nums+1)
|
tdSql.checkRows(self.row_nums+1)
|
||||||
tdSql.query("select count(c1+c3)+max(c2) ,abs(c1) from stb group by abs(c1) order by abs(c1)")
|
tdSql.query(f"select count(c1+c3)+max(c2) ,abs(c1) from {dbname}.stb group by abs(c1) order by abs(c1)")
|
||||||
tdSql.checkRows(self.row_nums+1)
|
tdSql.checkRows(self.row_nums+1)
|
||||||
tdSql.error("select count(c1+c3)+max(c2) ,abs(c1) ,abs(t1) from stb group by abs(c1) order by abs(t1)+c2")
|
tdSql.error(f"select count(c1+c3)+max(c2) ,abs(c1) ,abs(t1) from {dbname}.stb group by abs(c1) order by abs(t1)+c2")
|
||||||
tdSql.error("select count(c1+c3)+max(c2) ,abs(c1) from stb group by abs(c1) order by abs(c1)+c2")
|
tdSql.error(f"select count(c1+c3)+max(c2) ,abs(c1) from {dbname}.stb group by abs(c1) order by abs(c1)+c2")
|
||||||
tdSql.query("select abs(c1+c3)+abs(c2) , count(c1+c3)+count(c2) from stb group by abs(c1+c3)+abs(c2) order by abs(c1+c3)+abs(c2)")
|
tdSql.query(f"select abs(c1+c3)+abs(c2) , count(c1+c3)+count(c2) from {dbname}.stb group by abs(c1+c3)+abs(c2) order by abs(c1+c3)+abs(c2)")
|
||||||
tdSql.checkRows(self.row_nums+1)
|
tdSql.checkRows(self.row_nums+1)
|
||||||
|
|
||||||
tdSql.query("select count(c1) , count(t2) from stb where abs(c1+t2)=1 partition by tbname")
|
tdSql.query(f"select count(c1) , count(t2) from {dbname}.stb where abs(c1+t2)=1 partition by tbname")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.query("select count(c1) from stb where abs(c1+t2)=1 partition by tbname")
|
tdSql.query(f"select count(c1) from {dbname}.stb where abs(c1+t2)=1 partition by tbname")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
|
|
||||||
tdSql.query("select tbname , count(c1) from stb partition by tbname order by tbname")
|
tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname order by tbname")
|
||||||
tdSql.checkRows(self.tb_nums)
|
tdSql.checkRows(self.tb_nums)
|
||||||
tdSql.checkData(0,1,self.row_nums)
|
tdSql.checkData(0,1,self.row_nums)
|
||||||
|
|
||||||
tdSql.error("select tbname , count(c1) from stb partition by t1 order by t1")
|
tdSql.error(f"select tbname , count(c1) from {dbname}.stb partition by t1 order by t1")
|
||||||
tdSql.error("select tbname , count(t1) from stb partition by t1 order by t1")
|
tdSql.error(f"select tbname , count(t1) from {dbname}.stb partition by t1 order by t1")
|
||||||
tdSql.error("select tbname , count(t1) from stb partition by t2 order by t2")
|
tdSql.error(f"select tbname , count(t1) from {dbname}.stb partition by t2 order by t2")
|
||||||
|
|
||||||
# # bug need fix
|
# # bug need fix
|
||||||
# tdSql.query("select t2 , count(t1) from stb partition by t2 order by t2")
|
# tdSql.query(f"select t2 , count(t1) from {dbname}.stb partition by t2 order by t2")
|
||||||
# tdSql.checkRows(self.tb_nums)
|
# tdSql.checkRows(self.tb_nums)
|
||||||
|
|
||||||
tdSql.query("select tbname , count(c1) from stb partition by tbname order by tbname")
|
tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname order by tbname")
|
||||||
tdSql.checkRows(self.tb_nums)
|
tdSql.checkRows(self.tb_nums)
|
||||||
tdSql.checkData(0,1,self.row_nums)
|
tdSql.checkData(0,1,self.row_nums)
|
||||||
|
|
||||||
|
|
||||||
tdSql.error("select tbname , count(c1) from stb partition by t2 order by t2")
|
|
||||||
|
|
||||||
tdSql.query("select c2, count(c1) from stb partition by c2 order by c2 desc")
|
tdSql.error(f"select tbname , count(c1) from {dbname}.stb partition by t2 order by t2")
|
||||||
|
|
||||||
|
tdSql.query(f"select c2, count(c1) from {dbname}.stb partition by c2 order by c2 desc")
|
||||||
tdSql.checkRows(self.tb_nums+1)
|
tdSql.checkRows(self.tb_nums+1)
|
||||||
tdSql.checkData(0,1,self.tb_nums)
|
tdSql.checkData(0,1,self.tb_nums)
|
||||||
|
|
||||||
tdSql.error("select tbname , count(c1) from stb partition by c1 order by c2")
|
tdSql.error(f"select tbname , count(c1) from {dbname}.stb partition by c1 order by c2")
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select tbname , abs(t2) from stb partition by c2 order by t2")
|
tdSql.query(f"select tbname , abs(t2) from {dbname}.stb partition by c2 order by t2")
|
||||||
tdSql.checkRows(self.tb_nums*(self.row_nums+5))
|
tdSql.checkRows(self.tb_nums*(self.row_nums+5))
|
||||||
|
|
||||||
tdSql.query("select count(c1) , count(t2) from stb partition by c2 ")
|
tdSql.query(f"select count(c1) , count(t2) from {dbname}.stb partition by c2 ")
|
||||||
tdSql.checkRows(self.row_nums+1)
|
tdSql.checkRows(self.row_nums+1)
|
||||||
tdSql.checkData(0,1,self.row_nums)
|
tdSql.checkData(0,1,self.row_nums)
|
||||||
|
|
||||||
tdSql.query("select count(c1) , count(t2) ,c2 from stb partition by c2 order by c2")
|
tdSql.query(f"select count(c1) , count(t2) ,c2 from {dbname}.stb partition by c2 order by c2")
|
||||||
tdSql.checkRows(self.row_nums+1)
|
tdSql.checkRows(self.row_nums+1)
|
||||||
|
|
||||||
tdSql.query("select count(c1) , count(t1) ,max(c2) ,tbname from stb partition by tbname order by tbname")
|
tdSql.query(f"select count(c1) , count(t1) ,max(c2) ,tbname from {dbname}.stb partition by tbname order by tbname")
|
||||||
tdSql.checkRows(self.tb_nums)
|
tdSql.checkRows(self.tb_nums)
|
||||||
tdSql.checkCols(4)
|
tdSql.checkCols(4)
|
||||||
|
|
||||||
tdSql.query("select count(c1) , count(t2) ,t1 from stb partition by t1 order by t1")
|
tdSql.query(f"select count(c1) , count(t2) ,t1 from {dbname}.stb partition by t1 order by t1")
|
||||||
tdSql.checkRows(self.tb_nums)
|
tdSql.checkRows(self.tb_nums)
|
||||||
tdSql.checkData(0,0,self.row_nums)
|
tdSql.checkData(0,0,self.row_nums)
|
||||||
|
|
||||||
# bug need fix
|
# bug need fix
|
||||||
# tdSql.query("select count(c1) , count(t1) ,abs(c1) from stb partition by abs(c1) order by abs(c1)")
|
# tdSql.query(f"select count(c1) , count(t1) ,abs(c1) from {dbname}.stb partition by abs(c1) order by abs(c1)")
|
||||||
# tdSql.checkRows(self.row_nums+1)
|
# tdSql.checkRows(self.row_nums+1)
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select count(ceil(c2)) , count(floor(t2)) ,count(floor(c2)) from stb partition by abs(c2) order by abs(c2)")
|
|
||||||
|
tdSql.query(f"select count(ceil(c2)) , count(floor(t2)) ,count(floor(c2)) from {dbname}.stb partition by abs(c2) order by abs(c2)")
|
||||||
tdSql.checkRows(self.row_nums+1)
|
tdSql.checkRows(self.row_nums+1)
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select count(ceil(c1-2)) , count(floor(t2+1)) ,max(c2-c1) from stb partition by abs(floor(c1)) order by abs(floor(c1))")
|
tdSql.query(f"select count(ceil(c1-2)) , count(floor(t2+1)) ,max(c2-c1) from {dbname}.stb partition by abs(floor(c1)) order by abs(floor(c1))")
|
||||||
tdSql.checkRows(self.row_nums+1)
|
tdSql.checkRows(self.row_nums+1)
|
||||||
|
|
||||||
|
|
||||||
# interval
|
|
||||||
tdSql.query("select count(c1) from stb interval(2s) sliding(1s)")
|
# interval
|
||||||
|
tdSql.query(f"select count(c1) from {dbname}.stb interval(2s) sliding(1s)")
|
||||||
|
|
||||||
# bug need fix
|
# bug need fix
|
||||||
|
|
||||||
tdSql.query('select max(c1) from stb where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s) fill(NULL)')
|
tdSql.query(f'select max(c1) from {dbname}.stb where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s) fill(NULL)')
|
||||||
|
|
||||||
tdSql.query(" select tbname , count(c1) from stb partition by tbname interval(10s) slimit 5 soffset 1 ")
|
tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname interval(10s) slimit 5 soffset 1 ")
|
||||||
|
|
||||||
tdSql.query("select tbname , count(c1) from stb partition by tbname interval(10s)")
|
tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname interval(10s)")
|
||||||
|
|
||||||
tdSql.query("select tbname , count(c1) from sub_stb_1 partition by tbname interval(10s)")
|
tdSql.query(f"select tbname , count(c1) from {dbname}.sub_stb_1 partition by tbname interval(10s)")
|
||||||
tdSql.checkData(0,0,'sub_stb_1')
|
tdSql.checkData(0,0,'sub_stb_1')
|
||||||
tdSql.checkData(0,1,self.row_nums)
|
tdSql.checkData(0,1,self.row_nums)
|
||||||
|
|
||||||
# tdSql.query(" select tbname , count(c1) from stb partition by tbname order by tbname slimit 5 soffset 0 ")
|
# tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname order by tbname slimit 5 soffset 0 ")
|
||||||
# tdSql.checkRows(5)
|
# tdSql.checkRows(5)
|
||||||
|
|
||||||
# tdSql.query(" select tbname , count(c1) from stb partition by tbname order by tbname slimit 5 soffset 1 ")
|
# tdSql.query(f"select tbname , count(c1) from {dbname}.stb partition by tbname order by tbname slimit 5 soffset 1 ")
|
||||||
# tdSql.checkRows(5)
|
# tdSql.checkRows(5)
|
||||||
|
|
||||||
tdSql.query(" select tbname , count(c1) from sub_stb_1 partition by tbname interval(10s) sliding(5s) ")
|
tdSql.query(f"select tbname , count(c1) from {dbname}.sub_stb_1 partition by tbname interval(10s) sliding(5s) ")
|
||||||
|
|
||||||
tdSql.query(f'select max(c1) from stb where ts>={self.ts} and ts < {self.ts}+10000 partition by tbname interval(50s) sliding(30s)')
|
tdSql.query(f'select max(c1) from {dbname}.stb where ts>={self.ts} and ts < {self.ts}+10000 partition by tbname interval(50s) sliding(30s)')
|
||||||
tdSql.query(f'select max(c1) from stb where ts>={self.ts} and ts < {self.ts}+10000 interval(50s) sliding(30s)')
|
tdSql.query(f'select max(c1) from {dbname}.stb where ts>={self.ts} and ts < {self.ts}+10000 interval(50s) sliding(30s)')
|
||||||
tdSql.query(f'select tbname , count(c1) from stb where ts>={self.ts} and ts < {self.ts}+10000 partition by tbname interval(50s) sliding(30s)')
|
tdSql.query(f'select tbname , count(c1) from {dbname}.stb where ts>={self.ts} and ts < {self.ts}+10000 partition by tbname interval(50s) sliding(30s)')
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
self.prepare_datas("stb",self.tb_nums,self.row_nums)
|
self.prepare_datas("stb",self.tb_nums,self.row_nums)
|
||||||
self.basic_query()
|
self.basic_query()
|
||||||
|
dbname="db"
|
||||||
|
|
||||||
|
# # coverage case for taosd crash about bug fix
|
||||||
|
tdSql.query(f"select sum(c1) from {dbname}.stb where t2+10 >1 ")
|
||||||
|
tdSql.query(f"select count(c1),count(t1) from {dbname}.stb where -t2<1 ")
|
||||||
|
tdSql.query(f"select tbname ,max(ceil(c1)) from {dbname}.stb group by tbname ")
|
||||||
|
tdSql.query(f"select avg(abs(c1)) , tbname from {dbname}.stb group by tbname ")
|
||||||
|
tdSql.query(f"select t1,c1 from {dbname}.stb where abs(t2+c1)=1 ")
|
||||||
|
|
||||||
# # coverage case for taosd crash about bug fix
|
|
||||||
tdSql.query(" select sum(c1) from stb where t2+10 >1 ")
|
|
||||||
tdSql.query(" select count(c1),count(t1) from stb where -t2<1 ")
|
|
||||||
tdSql.query(" select tbname ,max(ceil(c1)) from stb group by tbname ")
|
|
||||||
tdSql.query(" select avg(abs(c1)) , tbname from stb group by tbname ")
|
|
||||||
tdSql.query(" select t1,c1 from stb where abs(t2+c1)=1 ")
|
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
tdLog.success("%s successfully executed" % __file__)
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
|
@ -10,9 +10,6 @@ import random
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
updatecfgDict = {'debugFlag': 143, "cDebugFlag": 143, "uDebugFlag": 143, "rpcDebugFlag": 143, "tmrDebugFlag": 143,
|
|
||||||
"jniDebugFlag": 143, "simDebugFlag": 143, "dDebugFlag": 143, "dDebugFlag": 143, "vDebugFlag": 143, "mDebugFlag": 143, "qDebugFlag": 143,
|
|
||||||
"wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "udfDebugFlag": 143}
|
|
||||||
|
|
||||||
def init(self, conn, logSql):
|
def init(self, conn, logSql):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
@ -26,22 +23,22 @@ class TDTestCase:
|
||||||
tdSql.execute("create table dbms.ntb (ts timestamp, c1 int, c2 bigint)")
|
tdSql.execute("create table dbms.ntb (ts timestamp, c1 int, c2 bigint)")
|
||||||
tdSql.execute("create table dbus.ntb (ts timestamp, c1 int, c2 bigint)")
|
tdSql.execute("create table dbus.ntb (ts timestamp, c1 int, c2 bigint)")
|
||||||
tdSql.execute("create table dbns.ntb (ts timestamp, c1 int, c2 bigint)")
|
tdSql.execute("create table dbns.ntb (ts timestamp, c1 int, c2 bigint)")
|
||||||
|
|
||||||
tdSql.execute("insert into dbms.ntb values ('2022-01-01 08:00:00.001', 1, 2)")
|
tdSql.execute("insert into dbms.ntb values ('2022-01-01 08:00:00.001', 1, 2)")
|
||||||
tdSql.execute("insert into dbms.ntb values ('2022-01-01 08:00:00.002', 3, 4)")
|
tdSql.execute("insert into dbms.ntb values ('2022-01-01 08:00:00.002', 3, 4)")
|
||||||
|
|
||||||
tdSql.execute("insert into dbus.ntb values ('2022-01-01 08:00:00.000001', 1, 2)")
|
tdSql.execute("insert into dbus.ntb values ('2022-01-01 08:00:00.000001', 1, 2)")
|
||||||
tdSql.execute("insert into dbus.ntb values ('2022-01-01 08:00:00.000002', 3, 4)")
|
tdSql.execute("insert into dbus.ntb values ('2022-01-01 08:00:00.000002', 3, 4)")
|
||||||
|
|
||||||
tdSql.execute("insert into dbns.ntb values ('2022-01-01 08:00:00.000000001', 1, 2)")
|
tdSql.execute("insert into dbns.ntb values ('2022-01-01 08:00:00.000000001', 1, 2)")
|
||||||
tdSql.execute("insert into dbns.ntb values ('2022-01-01 08:00:00.000000002', 3, 4)")
|
tdSql.execute("insert into dbns.ntb values ('2022-01-01 08:00:00.000000002', 3, 4)")
|
||||||
|
|
||||||
tdSql.query("select count(c1) from dbms.ntb interval(1a)")
|
tdSql.query("select count(c1) from dbms.ntb interval(1a)")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
|
|
||||||
tdSql.query("select count(c1) from dbus.ntb interval(1u)")
|
tdSql.query("select count(c1) from dbus.ntb interval(1u)")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
|
|
||||||
tdSql.query("select count(c1) from dbns.ntb interval(1b)")
|
tdSql.query("select count(c1) from dbns.ntb interval(1b)")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
|
|
||||||
|
|
|
@ -18,188 +18,117 @@ class TDTestCase:
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
dbname = "db"
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
"create table ntb(ts timestamp,c1 int,c2 double,c3 float)")
|
f"create table {dbname}.ntb(ts timestamp,c1 int,c2 double,c3 float)")
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
"insert into ntb values(now,1,1.0,10.5)(now+1s,10,-100.0,5.1)(now+10s,-1,15.1,5.0)")
|
f"insert into {dbname}.ntb values(now,1,1.0,10.5)(now+1s,10,-100.0,5.1)(now+10s,-1,15.1,5.0)")
|
||||||
|
|
||||||
tdSql.query("select diff(c1,0) from ntb")
|
tdSql.query(f"select diff(c1,0) from {dbname}.ntb")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 0, 9)
|
tdSql.checkData(0, 0, 9)
|
||||||
tdSql.checkData(1, 0, -11)
|
tdSql.checkData(1, 0, -11)
|
||||||
tdSql.query("select diff(c1,1) from ntb")
|
tdSql.query(f"select diff(c1,1) from {dbname}.ntb")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 0, 9)
|
tdSql.checkData(0, 0, 9)
|
||||||
tdSql.checkData(1, 0, None)
|
tdSql.checkData(1, 0, None)
|
||||||
|
|
||||||
tdSql.query("select diff(c2,0) from ntb")
|
tdSql.query(f"select diff(c2,0) from {dbname}.ntb")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 0, -101)
|
tdSql.checkData(0, 0, -101)
|
||||||
tdSql.checkData(1, 0, 115.1)
|
tdSql.checkData(1, 0, 115.1)
|
||||||
tdSql.query("select diff(c2,1) from ntb")
|
tdSql.query(f"select diff(c2,1) from {dbname}.ntb")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 0, None)
|
tdSql.checkData(0, 0, None)
|
||||||
tdSql.checkData(1, 0, 115.1)
|
tdSql.checkData(1, 0, 115.1)
|
||||||
|
|
||||||
tdSql.query("select diff(c3,0) from ntb")
|
tdSql.query(f"select diff(c3,0) from {dbname}.ntb")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 0, -5.4)
|
tdSql.checkData(0, 0, -5.4)
|
||||||
tdSql.checkData(1, 0, -0.1)
|
tdSql.checkData(1, 0, -0.1)
|
||||||
tdSql.query("select diff(c3,1) from ntb")
|
tdSql.query(f"select diff(c3,1) from {dbname}.ntb")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 0, None)
|
tdSql.checkData(0, 0, None)
|
||||||
tdSql.checkData(1, 0, None)
|
tdSql.checkData(1, 0, None)
|
||||||
|
|
||||||
tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
|
tdSql.execute(f'''create table {dbname}.stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
|
||||||
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''')
|
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''')
|
||||||
tdSql.execute("create table stb_1 using stb tags('beijing')")
|
tdSql.execute(f"create table {dbname}.stb_1 using {dbname}.stb tags('beijing')")
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
"insert into stb_1 values(%d, 0, 0, 0, 0, 0.0, 0.0, False, ' ', ' ', 0, 0, 0, 0)" % (self.ts - 1))
|
f"insert into {dbname}.stb_1 values(%d, 0, 0, 0, 0, 0.0, 0.0, False, ' ', ' ', 0, 0, 0, 0)" % (self.ts - 1))
|
||||||
|
|
||||||
# diff verifacation
|
# diff verifacation
|
||||||
tdSql.query("select diff(col1) from stb_1")
|
tdSql.query(f"select diff(col1) from {dbname}.stb_1")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
tdSql.query("select diff(col2) from stb_1")
|
tdSql.query(f"select diff(col2) from {dbname}.stb_1")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
tdSql.query("select diff(col3) from stb_1")
|
tdSql.query(f"select diff(col3) from {dbname}.stb_1")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
tdSql.query("select diff(col4) from stb_1")
|
tdSql.query(f"select diff(col4) from {dbname}.stb_1")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
tdSql.query("select diff(col5) from stb_1")
|
tdSql.query(f"select diff(col5) from {dbname}.stb_1")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
tdSql.query("select diff(col6) from stb_1")
|
tdSql.query(f"select diff(col6) from {dbname}.stb_1")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
tdSql.query("select diff(col7) from stb_1")
|
tdSql.query(f"select diff(col7) from {dbname}.stb_1")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
for i in range(self.rowNum):
|
for i in range(self.rowNum):
|
||||||
tdSql.execute("insert into stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
|
tdSql.execute(f"insert into {dbname}.stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
|
||||||
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1))
|
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1))
|
||||||
|
|
||||||
tdSql.error("select diff(ts) from stb")
|
tdSql.error(f"select diff(ts) from {dbname}.stb")
|
||||||
tdSql.error("select diff(ts) from stb_1")
|
tdSql.error(f"select diff(ts) from {dbname}.stb_1")
|
||||||
|
|
||||||
# tdSql.error("select diff(col7) from stb")
|
# tdSql.error(f"select diff(col7) from {dbname}.stb")
|
||||||
|
|
||||||
tdSql.error("select diff(col8) from stb")
|
tdSql.error(f"select diff(col8) from {dbname}.stb")
|
||||||
tdSql.error("select diff(col8) from stb_1")
|
tdSql.error(f"select diff(col8) from {dbname}.stb_1")
|
||||||
tdSql.error("select diff(col9) from stb")
|
tdSql.error(f"select diff(col9) from {dbname}.stb")
|
||||||
tdSql.error("select diff(col9) from stb_1")
|
tdSql.error(f"select diff(col9) from {dbname}.stb_1")
|
||||||
tdSql.error("select diff(col11) from stb_1")
|
tdSql.error(f"select diff(col11) from {dbname}.stb_1")
|
||||||
tdSql.error("select diff(col12) from stb_1")
|
tdSql.error(f"select diff(col12) from {dbname}.stb_1")
|
||||||
tdSql.error("select diff(col13) from stb_1")
|
tdSql.error(f"select diff(col13) from {dbname}.stb_1")
|
||||||
tdSql.error("select diff(col14) from stb_1")
|
tdSql.error(f"select diff(col14) from {dbname}.stb_1")
|
||||||
|
tdSql.query(f"select ts,diff(col1),ts from {dbname}.stb_1")
|
||||||
|
|
||||||
tdSql.query("select diff(col1) from stb_1")
|
tdSql.query(f"select diff(col1) from {dbname}.stb_1")
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(10)
|
||||||
|
|
||||||
tdSql.query("select diff(col2) from stb_1")
|
tdSql.query(f"select diff(col2) from {dbname}.stb_1")
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(10)
|
||||||
|
|
||||||
tdSql.query("select diff(col3) from stb_1")
|
tdSql.query(f"select diff(col3) from {dbname}.stb_1")
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(10)
|
||||||
|
|
||||||
tdSql.query("select diff(col4) from stb_1")
|
tdSql.query(f"select diff(col4) from {dbname}.stb_1")
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(10)
|
||||||
|
|
||||||
tdSql.query("select diff(col5) from stb_1")
|
tdSql.query(f"select diff(col5) from {dbname}.stb_1")
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(10)
|
||||||
|
|
||||||
tdSql.query("select diff(col6) from stb_1")
|
tdSql.query(f"select diff(col6) from {dbname}.stb_1")
|
||||||
tdSql.checkRows(10)
|
tdSql.checkRows(10)
|
||||||
|
|
||||||
# check selectivity
|
tdSql.execute(f'''create table {dbname}.stb1(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
|
||||||
tdSql.query("select ts, diff(col1), col2 from stb_1")
|
|
||||||
tdSql.checkRows(10)
|
|
||||||
tdSql.checkData(0, 0, "2018-09-17 09:00:00.000")
|
|
||||||
tdSql.checkData(1, 0, "2018-09-17 09:00:00.001")
|
|
||||||
tdSql.checkData(2, 0, "2018-09-17 09:00:00.002")
|
|
||||||
tdSql.checkData(3, 0, "2018-09-17 09:00:00.003")
|
|
||||||
tdSql.checkData(4, 0, "2018-09-17 09:00:00.004")
|
|
||||||
tdSql.checkData(5, 0, "2018-09-17 09:00:00.005")
|
|
||||||
tdSql.checkData(6, 0, "2018-09-17 09:00:00.006")
|
|
||||||
tdSql.checkData(7, 0, "2018-09-17 09:00:00.007")
|
|
||||||
tdSql.checkData(8, 0, "2018-09-17 09:00:00.008")
|
|
||||||
tdSql.checkData(9, 0, "2018-09-17 09:00:00.009")
|
|
||||||
|
|
||||||
tdSql.checkData(0, 1, 1)
|
|
||||||
tdSql.checkData(1, 1, 1)
|
|
||||||
tdSql.checkData(2, 1, 1)
|
|
||||||
tdSql.checkData(3, 1, 1)
|
|
||||||
tdSql.checkData(4, 1, 1)
|
|
||||||
tdSql.checkData(5, 1, 1)
|
|
||||||
tdSql.checkData(6, 1, 1)
|
|
||||||
tdSql.checkData(7, 1, 1)
|
|
||||||
tdSql.checkData(8, 1, 1)
|
|
||||||
tdSql.checkData(9, 1, 1)
|
|
||||||
|
|
||||||
tdSql.checkData(0, 2, 0)
|
|
||||||
tdSql.checkData(1, 2, 1)
|
|
||||||
tdSql.checkData(2, 2, 2)
|
|
||||||
tdSql.checkData(3, 2, 3)
|
|
||||||
tdSql.checkData(4, 2, 4)
|
|
||||||
tdSql.checkData(5, 2, 5)
|
|
||||||
tdSql.checkData(6, 2, 6)
|
|
||||||
tdSql.checkData(7, 2, 7)
|
|
||||||
tdSql.checkData(8, 2, 8)
|
|
||||||
tdSql.checkData(9, 2, 9)
|
|
||||||
|
|
||||||
tdSql.query("select ts, diff(col1), col2 from stb order by ts")
|
|
||||||
tdSql.checkRows(10)
|
|
||||||
|
|
||||||
tdSql.checkData(0, 0, "2018-09-17 09:00:00.000")
|
|
||||||
tdSql.checkData(1, 0, "2018-09-17 09:00:00.001")
|
|
||||||
tdSql.checkData(2, 0, "2018-09-17 09:00:00.002")
|
|
||||||
tdSql.checkData(3, 0, "2018-09-17 09:00:00.003")
|
|
||||||
tdSql.checkData(4, 0, "2018-09-17 09:00:00.004")
|
|
||||||
tdSql.checkData(5, 0, "2018-09-17 09:00:00.005")
|
|
||||||
tdSql.checkData(6, 0, "2018-09-17 09:00:00.006")
|
|
||||||
tdSql.checkData(7, 0, "2018-09-17 09:00:00.007")
|
|
||||||
tdSql.checkData(8, 0, "2018-09-17 09:00:00.008")
|
|
||||||
tdSql.checkData(9, 0, "2018-09-17 09:00:00.009")
|
|
||||||
|
|
||||||
tdSql.checkData(0, 1, 1)
|
|
||||||
tdSql.checkData(1, 1, 1)
|
|
||||||
tdSql.checkData(2, 1, 1)
|
|
||||||
tdSql.checkData(3, 1, 1)
|
|
||||||
tdSql.checkData(4, 1, 1)
|
|
||||||
tdSql.checkData(5, 1, 1)
|
|
||||||
tdSql.checkData(6, 1, 1)
|
|
||||||
tdSql.checkData(7, 1, 1)
|
|
||||||
tdSql.checkData(8, 1, 1)
|
|
||||||
tdSql.checkData(9, 1, 1)
|
|
||||||
|
|
||||||
tdSql.checkData(0, 2, 0)
|
|
||||||
tdSql.checkData(1, 2, 1)
|
|
||||||
tdSql.checkData(2, 2, 2)
|
|
||||||
tdSql.checkData(3, 2, 3)
|
|
||||||
tdSql.checkData(4, 2, 4)
|
|
||||||
tdSql.checkData(5, 2, 5)
|
|
||||||
tdSql.checkData(6, 2, 6)
|
|
||||||
tdSql.checkData(7, 2, 7)
|
|
||||||
tdSql.checkData(8, 2, 8)
|
|
||||||
tdSql.checkData(9, 2, 9)
|
|
||||||
|
|
||||||
|
|
||||||
tdSql.execute('''create table stb1(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
|
|
||||||
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''')
|
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''')
|
||||||
tdSql.execute("create table stb1_1 using stb tags('shanghai')")
|
tdSql.execute(f"create table {dbname}.stb1_1 using {dbname}.stb tags('shanghai')")
|
||||||
|
|
||||||
for i in range(self.rowNum):
|
for i in range(self.rowNum):
|
||||||
tdSql.execute("insert into stb1_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
|
tdSql.execute(f"insert into {dbname}.stb1_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
|
||||||
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1))
|
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1))
|
||||||
for i in range(self.rowNum):
|
for i in range(self.rowNum):
|
||||||
tdSql.execute("insert into stb1_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
|
tdSql.execute(f"insert into {dbname}.stb1_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
|
||||||
% (self.ts - i-1, i-1, i-1, i-1, i-1, -i - 0.1, -i - 0.1, -i % 2, i - 1, i - 1, i + 1, i + 1, i + 1, i + 1))
|
% (self.ts - i-1, i-1, i-1, i-1, i-1, -i - 0.1, -i - 0.1, -i % 2, i - 1, i - 1, i + 1, i + 1, i + 1, i + 1))
|
||||||
tdSql.query("select diff(col1,0) from stb1_1")
|
tdSql.query(f"select diff(col1,0) from {dbname}.stb1_1")
|
||||||
tdSql.checkRows(19)
|
tdSql.checkRows(19)
|
||||||
tdSql.query("select diff(col1,1) from stb1_1")
|
tdSql.query(f"select diff(col1,1) from {dbname}.stb1_1")
|
||||||
tdSql.checkRows(19)
|
tdSql.checkRows(19)
|
||||||
tdSql.checkData(0,0,None)
|
tdSql.checkData(0,0,None)
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@ class TDTestCase:
|
||||||
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
|
||||||
|
dbname = "db"
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step1:create table")
|
tdLog.printNoPrefix("==========step1:create table")
|
||||||
tdSql.execute("create stable db.stb1 (ts timestamp, c1 int, c2 int) tags(t0 tinyint, t1 int, t2 int)")
|
tdSql.execute("create stable db.stb1 (ts timestamp, c1 int, c2 int) tags(t0 tinyint, t1 int, t2 int)")
|
||||||
tdSql.execute("create stable db.stb2 (ts timestamp, c2 int, c3 binary(16)) tags(t2 binary(16), t3 binary(16), t4 int)")
|
tdSql.execute("create stable db.stb2 (ts timestamp, c2 int, c3 binary(16)) tags(t2 binary(16), t3 binary(16), t4 int)")
|
||||||
|
@ -34,223 +36,224 @@ class TDTestCase:
|
||||||
tdSql.execute(f"insert into db.t0{i} values (now-9d, {i}, '{(i+2)%3}')")
|
tdSql.execute(f"insert into db.t0{i} values (now-9d, {i}, '{(i+2)%3}')")
|
||||||
tdSql.execute(f"insert into db.t0{i} values (now-8d, {i}, '{(i)%3}')")
|
tdSql.execute(f"insert into db.t0{i} values (now-8d, {i}, '{(i)%3}')")
|
||||||
tdSql.execute(f"insert into db.t0{i} (ts )values (now-7d)")
|
tdSql.execute(f"insert into db.t0{i} (ts )values (now-7d)")
|
||||||
# tdSql.execute("create table db.t100num using db.stb1 tags(null, null, null)")
|
tdSql.execute("create table db.t100num using db.stb1 tags(null, null, null)")
|
||||||
# tdSql.execute("create table db.t0100num using db.stb2 tags(null, null, null)")
|
tdSql.execute("create table db.t0100num using db.stb2 tags(null, null, null)")
|
||||||
# tdSql.execute(f"insert into db.t100num values (now-10d, {tbnum-1}, 1)")
|
tdSql.execute(f"insert into db.t100num values (now-10d, {tbnum-1}, 1)")
|
||||||
# tdSql.execute(f"insert into db.t100num values (now-9d, {tbnum-1}, 0)")
|
tdSql.execute(f"insert into db.t100num values (now-9d, {tbnum-1}, 0)")
|
||||||
# tdSql.execute(f"insert into db.t100num values (now-8d, {tbnum-1}, 2)")
|
tdSql.execute(f"insert into db.t100num values (now-8d, {tbnum-1}, 2)")
|
||||||
# tdSql.execute(f"insert into db.t100num (ts )values (now-7d)")
|
tdSql.execute(f"insert into db.t100num (ts )values (now-7d)")
|
||||||
# tdSql.execute(f"insert into db.t0100num values (now-10d, {tbnum-1}, 1)")
|
tdSql.execute(f"insert into db.t0100num values (now-10d, {tbnum-1}, 1)")
|
||||||
# tdSql.execute(f"insert into db.t0100num values (now-9d, {tbnum-1}, 0)")
|
tdSql.execute(f"insert into db.t0100num values (now-9d, {tbnum-1}, 0)")
|
||||||
# tdSql.execute(f"insert into db.t0100num values (now-8d, {tbnum-1}, 2)")
|
tdSql.execute(f"insert into db.t0100num values (now-8d, {tbnum-1}, 2)")
|
||||||
# tdSql.execute(f"insert into db.t0100num (ts )values (now-7d)")
|
tdSql.execute(f"insert into db.t0100num (ts )values (now-7d)")
|
||||||
|
|
||||||
#========== distinct multi-data-coloumn ==========
|
# #========== distinct multi-data-coloumn ==========
|
||||||
# tdSql.query(f"select distinct c1 from stb1 where c1 <{tbnum}")
|
tdSql.query(f"select distinct c1 from {dbname}.stb1 where c1 <{tbnum}")
|
||||||
# tdSql.checkRows(tbnum)
|
tdSql.checkRows(tbnum)
|
||||||
# tdSql.query(f"select distinct c2 from stb1")
|
tdSql.query(f"select distinct c2 from {dbname}.stb1")
|
||||||
# tdSql.checkRows(4)
|
|
||||||
# tdSql.query(f"select distinct c1,c2 from stb1 where c1 <{tbnum}")
|
|
||||||
# tdSql.checkRows(tbnum*3)
|
|
||||||
# tdSql.query(f"select distinct c1,c1 from stb1 where c1 <{tbnum}")
|
|
||||||
# tdSql.checkRows(tbnum)
|
|
||||||
# tdSql.query(f"select distinct c1,c2 from stb1 where c1 <{tbnum} limit 3")
|
|
||||||
# tdSql.checkRows(3)
|
|
||||||
# tdSql.query(f"select distinct c1,c2 from stb1 where c1 <{tbnum} limit 3 offset {tbnum*3-2}")
|
|
||||||
# tdSql.checkRows(2)
|
|
||||||
|
|
||||||
tdSql.query(f"select distinct c1 from t1 where c1 <{tbnum}")
|
|
||||||
tdSql.checkRows(1)
|
|
||||||
tdSql.query(f"select distinct c2 from t1")
|
|
||||||
tdSql.checkRows(4)
|
tdSql.checkRows(4)
|
||||||
tdSql.query(f"select distinct c1,c2 from t1 where c1 <{tbnum}")
|
tdSql.query(f"select distinct c1,c2 from {dbname}.stb1 where c1 <{tbnum}")
|
||||||
|
tdSql.checkRows(tbnum*3)
|
||||||
|
tdSql.query(f"select distinct c1,c1 from {dbname}.stb1 where c1 <{tbnum}")
|
||||||
|
tdSql.checkRows(tbnum)
|
||||||
|
tdSql.query(f"select distinct c1,c2 from {dbname}.stb1 where c1 <{tbnum} limit 3")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
tdSql.query(f"select distinct c1,c1 from t1 ")
|
tdSql.query(f"select distinct c1,c2 from {dbname}.stb1 where c1 <{tbnum} limit 3 offset {tbnum*3-2}")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.query(f"select distinct c1,c1 from t1 where c1 <{tbnum}")
|
|
||||||
|
tdSql.query(f"select distinct c1 from {dbname}.t1 where c1 <{tbnum}")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.query(f"select distinct c1,c2 from t1 where c1 <{tbnum} limit 3")
|
tdSql.query(f"select distinct c2 from {dbname}.t1")
|
||||||
|
tdSql.checkRows(4)
|
||||||
|
tdSql.query(f"select distinct c1,c2 from {dbname}.t1 where c1 <{tbnum}")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
tdSql.query(f"select distinct c1,c2 from t1 where c1 <{tbnum} limit 3 offset 2")
|
tdSql.query(f"select distinct c1,c1 from {dbname}.t1 ")
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
tdSql.query(f"select distinct c1,c1 from {dbname}.t1 where c1 <{tbnum}")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.query(f"select distinct c1,c2 from {dbname}.t1 where c1 <{tbnum} limit 3")
|
||||||
|
tdSql.checkRows(3)
|
||||||
|
tdSql.query(f"select distinct c1,c2 from {dbname}.t1 where c1 <{tbnum} limit 3 offset 2")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
# tdSql.query(f"select distinct c3 from stb2 where c2 <{tbnum} ")
|
# tdSql.query(f"select distinct c3 from {dbname}.stb2 where c2 <{tbnum} ")
|
||||||
# tdSql.checkRows(3)
|
# tdSql.checkRows(3)
|
||||||
# tdSql.query(f"select distinct c3, c2 from stb2 where c2 <{tbnum} limit 2")
|
# tdSql.query(f"select distinct c3, c2 from {dbname}.stb2 where c2 <{tbnum} limit 2")
|
||||||
# tdSql.checkRows(2)
|
# tdSql.checkRows(2)
|
||||||
|
|
||||||
# tdSql.error("select distinct c5 from stb1")
|
# tdSql.error(f"select distinct c5 from {dbname}.stb1")
|
||||||
tdSql.error("select distinct c5 from t1")
|
tdSql.error(f"select distinct c5 from {dbname}.t1")
|
||||||
tdSql.error("select distinct c1 from db.*")
|
tdSql.error(f"select distinct c1 from db.*")
|
||||||
tdSql.error("select c2, distinct c1 from stb1")
|
tdSql.error(f"select c2, distinct c1 from {dbname}.stb1")
|
||||||
tdSql.error("select c2, distinct c1 from t1")
|
tdSql.error(f"select c2, distinct c1 from {dbname}.t1")
|
||||||
tdSql.error("select distinct c2 from ")
|
tdSql.error(f"select distinct c2 from ")
|
||||||
tdSql.error("distinct c2 from stb1")
|
tdSql.error("distinct c2 from {dbname}.stb1")
|
||||||
tdSql.error("distinct c2 from t1")
|
tdSql.error("distinct c2 from {dbname}.t1")
|
||||||
tdSql.error("select distinct c1, c2, c3 from stb1")
|
tdSql.error(f"select distinct c1, c2, c3 from {dbname}.stb1")
|
||||||
tdSql.error("select distinct c1, c2, c3 from t1")
|
tdSql.error(f"select distinct c1, c2, c3 from {dbname}.t1")
|
||||||
tdSql.error("select distinct stb1.c1, stb1.c2, stb2.c2, stb2.c3 from stb1")
|
tdSql.error(f"select distinct stb1.c1, stb1.c2, stb2.c2, stb2.c3 from {dbname}.stb1")
|
||||||
tdSql.error("select distinct stb1.c1, stb1.c2, stb2.c2, stb2.c3 from t1")
|
tdSql.error(f"select distinct stb1.c1, stb1.c2, stb2.c2, stb2.c3 from {dbname}.t1")
|
||||||
tdSql.error("select distinct t1.c1, t1.c2, t2.c1, t2.c2 from t1")
|
tdSql.error(f"select distinct t1.c1, t1.c2, t2.c1, t2.c2 from {dbname}.t1")
|
||||||
# tdSql.query(f"select distinct c1 c2, c2 c3 from stb1 where c1 <{tbnum}")
|
tdSql.query(f"select distinct c1 c2, c2 c3 from {dbname}.stb1 where c1 <{tbnum}")
|
||||||
# tdSql.checkRows(tbnum*3)
|
tdSql.checkRows(tbnum*3)
|
||||||
tdSql.query(f"select distinct c1 c2, c2 c3 from t1 where c1 <{tbnum}")
|
tdSql.query(f"select distinct c1 c2, c2 c3 from {dbname}.t1 where c1 <{tbnum}")
|
||||||
tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
# tdSql.error("select distinct c1, c2 from stb1 order by ts")
|
tdSql.error(f"select distinct c1, c2 from {dbname}.stb1 order by ts")
|
||||||
tdSql.error("select distinct c1, c2 from t1 order by ts")
|
tdSql.error(f"select distinct c1, c2 from {dbname}.t1 order by ts")
|
||||||
# tdSql.error("select distinct c1, ts from stb1 group by c2")
|
tdSql.error(f"select distinct c1, ts from {dbname}.stb1 group by c2")
|
||||||
tdSql.error("select distinct c1, ts from t1 group by c2")
|
tdSql.error(f"select distinct c1, ts from {dbname}.t1 group by c2")
|
||||||
# tdSql.error("select distinct c1, max(c2) from stb1 ")
|
tdSql.query(f"select distinct c1, max(c2) from {dbname}.stb1 ")
|
||||||
# tdSql.error("select distinct c1, max(c2) from t1 ")
|
tdSql.query(f"select distinct c1, max(c2) from {dbname}.t1 ")
|
||||||
# tdSql.error("select max(c2), distinct c1 from stb1 ")
|
tdSql.error(f"select max(c2), distinct c1 from {dbname}.stb1 ")
|
||||||
tdSql.error("select max(c2), distinct c1 from t1 ")
|
tdSql.error(f"select max(c2), distinct c1 from {dbname}.t1 ")
|
||||||
# tdSql.error("select distinct c1, c2 from stb1 where c1 > 3 group by t0")
|
tdSql.error(f"select distinct c1, c2 from {dbname}.stb1 where c1 > 3 group by t0")
|
||||||
tdSql.error("select distinct c1, c2 from t1 where c1 > 3 group by t0")
|
tdSql.error(f"select distinct c1, c2 from {dbname}.t1 where c1 > 3 group by t0")
|
||||||
# tdSql.error("select distinct c1, c2 from stb1 where c1 > 3 interval(1d) ")
|
tdSql.error(f"select distinct c1, c2 from {dbname}.stb1 where c1 > 3 interval(1d) ")
|
||||||
tdSql.error("select distinct c1, c2 from t1 where c1 > 3 interval(1d) ")
|
tdSql.error(f"select distinct c1, c2 from {dbname}.t1 where c1 > 3 interval(1d) ")
|
||||||
# tdSql.error("select distinct c1, c2 from stb1 where c1 > 3 interval(1d) fill(next)")
|
tdSql.error(f"select distinct c1, c2 from {dbname}.stb1 where c1 > 3 interval(1d) fill(next)")
|
||||||
tdSql.error("select distinct c1, c2 from t1 where c1 > 3 interval(1d) fill(next)")
|
tdSql.error(f"select distinct c1, c2 from {dbname}.t1 where c1 > 3 interval(1d) fill(next)")
|
||||||
# tdSql.error("select distinct c1, c2 from stb1 where ts > now-10d and ts < now interval(1d) fill(next)")
|
tdSql.error(f"select distinct c1, c2 from {dbname}.stb1 where ts > now-10d and ts < now interval(1d) fill(next)")
|
||||||
tdSql.error("select distinct c1, c2 from t1 where ts > now-10d and ts < now interval(1d) fill(next)")
|
tdSql.error(f"select distinct c1, c2 from {dbname}.t1 where ts > now-10d and ts < now interval(1d) fill(next)")
|
||||||
# tdSql.error("select distinct c1, c2 from stb1 where c1 > 3 slimit 1")
|
tdSql.error(f"select distinct c1, c2 from {dbname}.stb1 where c1 > 3 slimit 1")
|
||||||
# tdSql.error("select distinct c1, c2 from t1 where c1 > 3 slimit 1")
|
tdSql.error(f"select distinct c1, c2 from {dbname}.t1 where c1 > 3 slimit 1")
|
||||||
# tdSql.query(f"select distinct c1, c2 from stb1 where c1 between {tbnum-2} and {tbnum} ")
|
tdSql.query(f"select distinct c1, c2 from {dbname}.stb1 where c1 between {tbnum-2} and {tbnum} ")
|
||||||
# tdSql.checkRows(6)
|
tdSql.checkRows(6)
|
||||||
tdSql.query(f"select distinct c1, c2 from t1 where c1 between {tbnum-2} and {tbnum} ")
|
tdSql.query(f"select distinct c1, c2 from {dbname}.t1 where c1 between {tbnum-2} and {tbnum} ")
|
||||||
# tdSql.checkRows(1)
|
# tdSql.checkRows(1)
|
||||||
# tdSql.query("select distinct c1, c2 from stb1 where c1 in (1,2,3,4,5)")
|
tdSql.query(f"select distinct c1, c2 from {dbname}.stb1 where c1 in (1,2,3,4,5)")
|
||||||
# tdSql.checkRows(15)
|
tdSql.checkRows(15)
|
||||||
tdSql.query("select distinct c1, c2 from t1 where c1 in (1,2,3,4,5)")
|
tdSql.query(f"select distinct c1, c2 from {dbname}.t1 where c1 in (1,2,3,4,5)")
|
||||||
# tdSql.checkRows(1)
|
# tdSql.checkRows(1)
|
||||||
# tdSql.query("select distinct c1, c2 from stb1 where c1 in (100,1000,10000)")
|
tdSql.query(f"select distinct c1, c2 from {dbname}.stb1 where c1 in (100,1000,10000)")
|
||||||
# tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
tdSql.query("select distinct c1, c2 from t1 where c1 in (100,1000,10000)")
|
tdSql.query(f"select distinct c1, c2 from {dbname}.t1 where c1 in (100,1000,10000)")
|
||||||
# tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
# tdSql.query(f"select distinct c1,c2 from (select * from stb1 where c1 > {tbnum-2}) ")
|
tdSql.query(f"select distinct c1,c2 from (select * from {dbname}.stb1 where c1 > {tbnum-2}) ")
|
||||||
# tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
# tdSql.query(f"select distinct c1,c2 from (select * from t1 where c1 < {tbnum}) ")
|
tdSql.query(f"select distinct c1,c2 from (select * from {dbname}.t1 where c1 < {tbnum}) ")
|
||||||
# tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
# tdSql.query(f"select distinct c1,c2 from (select * from stb1 where t2 !=0 and t2 != 1) ")
|
tdSql.query(f"select distinct c1,c2 from (select * from {dbname}.stb1 where t2 !=0 and t2 != 1) ")
|
||||||
# tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
# tdSql.error("select distinct c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) ")
|
tdSql.query(f"select distinct c1, c2 from (select distinct c1, c2 from {dbname}.stb1 where t0 > 2 and t1 < 3) ")
|
||||||
# tdSql.error("select c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) ")
|
tdSql.query(f"select c1, c2 from (select distinct c1, c2 from {dbname}.stb1 where t0 > 2 and t1 < 3) ")
|
||||||
# tdSql.query("select distinct c1, c2 from (select c2, c1 from stb1 where c1 > 2 ) where c1 < 4")
|
tdSql.query(f"select distinct c1, c2 from (select c2, c1 from {dbname}.stb1 where c1 > 2 ) where c1 < 4")
|
||||||
# tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
# tdSql.error("select distinct c1, c2 from (select c1 from stb1 where t0 > 2 ) where t1 < 3")
|
tdSql.error(f"select distinct c1, c2 from (select c1 from {dbname}.stb1 where t0 > 2 ) where t1 < 3")
|
||||||
# tdSql.error("select distinct c1, c2 from (select c2, c1 from stb1 where c1 > 2 order by ts)")
|
tdSql.query(f"select distinct c1, c2 from (select c2, c1 from {dbname}.stb1 where c1 > 2 order by ts)")
|
||||||
# tdSql.error("select distinct c1, c2 from (select c2, c1 from t1 where c1 > 2 order by ts)")
|
tdSql.query(f"select distinct c1, c2 from (select c2, c1 from {dbname}.t1 where c1 > 2 order by ts)")
|
||||||
# tdSql.error("select distinct c1, c2 from (select c2, c1 from stb1 where c1 > 2 group by c1)")
|
tdSql.error(f"select distinct c1, c2 from (select c2, c1 from {dbname}.stb1 where c1 > 2 group by c1)")
|
||||||
# tdSql.error("select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from stb1 group by c1)")
|
tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.stb1 group by c1)")
|
||||||
# tdSql.error("select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from t1 group by c1)")
|
tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.t1 group by c1)")
|
||||||
# tdSql.query("select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from stb1 )")
|
tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.stb1 )")
|
||||||
# tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
# tdSql.query("select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from t1 )")
|
tdSql.query(f"select distinct c1, c2 from (select max(c1) c1, max(c2) c2 from {dbname}.t1 )")
|
||||||
# tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
# tdSql.error("select distinct stb1.c1, stb1.c2 from stb1 , stb2 where stb1.ts=stb2.ts and stb1.t2=stb2.t4")
|
tdSql.query(f"select distinct stb1.c1, stb1.c2 from {dbname}.stb1, {dbname}.stb2 where stb1.ts=stb2.ts and stb1.t2=stb2.t4")
|
||||||
# tdSql.error("select distinct t1.c1, t1.c2 from t1 , t2 where t1.ts=t2.ts ")
|
tdSql.query(f"select distinct t1.c1, t1.c2 from {dbname}.t1, {dbname}.t2 where t1.ts=t2.ts ")
|
||||||
|
|
||||||
# tdSql.error("select distinct c1, c2 from (select count(c1) c1, count(c2) c2 from stb1 group by ts)")
|
tdSql.query(f"select distinct c1, c2 from (select count(c1) c1, count(c2) c2 from {dbname}.stb1 group by ts)")
|
||||||
# tdSql.error("select distinct c1, c2 from (select count(c1) c1, count(c2) c2 from t1 group by ts)")
|
tdSql.query(f"select distinct c1, c2 from (select count(c1) c1, count(c2) c2 from {dbname}.t1 group by ts)")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# #========== suport distinct multi-tags-coloumn ==========
|
#========== suport distinct multi-tags-coloumn ==========
|
||||||
# tdSql.query("select distinct t1 from stb1")
|
tdSql.query(f"select distinct t1 from {dbname}.stb1")
|
||||||
# tdSql.checkRows(maxRemainderNum+1)
|
tdSql.checkRows(maxRemainderNum+1)
|
||||||
# tdSql.query("select distinct t0, t1 from stb1")
|
tdSql.query(f"select distinct t0, t1 from {dbname}.stb1")
|
||||||
# tdSql.checkRows(maxRemainderNum+1)
|
tdSql.checkRows(maxRemainderNum+1)
|
||||||
# tdSql.query("select distinct t1, t0 from stb1")
|
tdSql.query(f"select distinct t1, t0 from {dbname}.stb1")
|
||||||
# tdSql.checkRows(maxRemainderNum+1)
|
tdSql.checkRows(maxRemainderNum+1)
|
||||||
# tdSql.query("select distinct t1, t2 from stb1")
|
tdSql.query(f"select distinct t1, t2 from {dbname}.stb1")
|
||||||
# tdSql.checkRows(maxRemainderNum*2+1)
|
tdSql.checkRows(maxRemainderNum*2+1)
|
||||||
# tdSql.query("select distinct t0, t1, t2 from stb1")
|
tdSql.query(f"select distinct t0, t1, t2 from {dbname}.stb1")
|
||||||
# tdSql.checkRows(maxRemainderNum*2+1)
|
tdSql.checkRows(maxRemainderNum*2+1)
|
||||||
# tdSql.query("select distinct t0 t1, t1 t2 from stb1")
|
tdSql.query(f"select distinct t0 t1, t1 t2 from {dbname}.stb1")
|
||||||
# tdSql.checkRows(maxRemainderNum+1)
|
tdSql.checkRows(maxRemainderNum+1)
|
||||||
# tdSql.query("select distinct t0, t0, t0 from stb1")
|
tdSql.query(f"select distinct t0, t0, t0 from {dbname}.stb1")
|
||||||
# tdSql.checkRows(maxRemainderNum+1)
|
tdSql.checkRows(maxRemainderNum+1)
|
||||||
# tdSql.query("select distinct t0, t1 from t1")
|
tdSql.query(f"select distinct t0, t1 from {dbname}.t1")
|
||||||
# tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
# tdSql.query("select distinct t0, t1 from t100num")
|
tdSql.query(f"select distinct t0, t1 from {dbname}.t100num")
|
||||||
# tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
# tdSql.query("select distinct t3 from stb2")
|
tdSql.query(f"select distinct t3 from {dbname}.stb2")
|
||||||
# tdSql.checkRows(maxRemainderNum+1)
|
tdSql.checkRows(maxRemainderNum+1)
|
||||||
# tdSql.query("select distinct t2, t3 from stb2")
|
tdSql.query(f"select distinct t2, t3 from {dbname}.stb2")
|
||||||
# tdSql.checkRows(maxRemainderNum+1)
|
tdSql.checkRows(maxRemainderNum+1)
|
||||||
# tdSql.query("select distinct t3, t2 from stb2")
|
tdSql.query(f"select distinct t3, t2 from {dbname}.stb2")
|
||||||
# tdSql.checkRows(maxRemainderNum+1)
|
tdSql.checkRows(maxRemainderNum+1)
|
||||||
# tdSql.query("select distinct t4, t2 from stb2")
|
tdSql.query(f"select distinct t4, t2 from {dbname}.stb2")
|
||||||
# tdSql.checkRows(maxRemainderNum*3+1)
|
tdSql.checkRows(maxRemainderNum*3+1)
|
||||||
# tdSql.query("select distinct t2, t3, t4 from stb2")
|
tdSql.query(f"select distinct t2, t3, t4 from {dbname}.stb2")
|
||||||
# tdSql.checkRows(maxRemainderNum*3+1)
|
tdSql.checkRows(maxRemainderNum*3+1)
|
||||||
# tdSql.query("select distinct t2 t1, t3 t2 from stb2")
|
tdSql.query(f"select distinct t2 t1, t3 t2 from {dbname}.stb2")
|
||||||
# tdSql.checkRows(maxRemainderNum+1)
|
tdSql.checkRows(maxRemainderNum+1)
|
||||||
# tdSql.query("select distinct t3, t3, t3 from stb2")
|
tdSql.query(f"select distinct t3, t3, t3 from {dbname}.stb2")
|
||||||
# tdSql.checkRows(maxRemainderNum+1)
|
tdSql.checkRows(maxRemainderNum+1)
|
||||||
# tdSql.query("select distinct t2, t3 from t01")
|
tdSql.query(f"select distinct t2, t3 from {dbname}.t01")
|
||||||
# tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
# tdSql.query("select distinct t3, t4 from t0100num")
|
tdSql.query(f"select distinct t3, t4 from {dbname}.t0100num")
|
||||||
# tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
|
|
||||||
# ########## should be error #########
|
########## should be error #########
|
||||||
# tdSql.error("select distinct from stb1")
|
tdSql.error(f"select distinct from {dbname}.stb1")
|
||||||
# tdSql.error("select distinct t3 from stb1")
|
tdSql.error(f"select distinct t3 from {dbname}.stb1")
|
||||||
# tdSql.error("select distinct t1 from db.*")
|
tdSql.error(f"select distinct t1 from db.*")
|
||||||
# tdSql.error("select distinct t2 from ")
|
tdSql.error(f"select distinct t2 from ")
|
||||||
# tdSql.error("distinct t2 from stb1")
|
tdSql.error(f"distinct t2 from {dbname}.stb1")
|
||||||
# tdSql.error("select distinct stb1")
|
tdSql.error(f"select distinct stb1")
|
||||||
# tdSql.error("select distinct t0, t1, t2, t3 from stb1")
|
tdSql.error(f"select distinct t0, t1, t2, t3 from {dbname}.stb1")
|
||||||
# tdSql.error("select distinct stb1.t0, stb1.t1, stb2.t2, stb2.t3 from stb1")
|
tdSql.error(f"select distinct stb1.t0, stb1.t1, stb2.t2, stb2.t3 from {dbname}.stb1")
|
||||||
|
|
||||||
# tdSql.error("select dist t0 from stb1")
|
tdSql.error(f"select dist t0 from {dbname}.stb1")
|
||||||
# tdSql.error("select distinct stb2.t2, stb2.t3 from stb1")
|
tdSql.error(f"select distinct stb2.t2, stb2.t3 from {dbname}.stb1")
|
||||||
# tdSql.error("select distinct stb2.t2 t1, stb2.t3 t2 from stb1")
|
tdSql.error(f"select distinct stb2.t2 t1, stb2.t3 t2 from {dbname}.stb1")
|
||||||
|
|
||||||
# tdSql.error("select distinct t0, t1 from t1 where t0 < 7")
|
tdSql.query(f"select distinct t0, t1 from {dbname}.t1 where t0 < 7")
|
||||||
|
|
||||||
# ########## add where condition ##########
|
########## add where condition ##########
|
||||||
# tdSql.query("select distinct t0, t1 from stb1 where t1 > 3")
|
tdSql.query(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3")
|
||||||
# tdSql.checkRows(3)
|
tdSql.checkRows(3)
|
||||||
# tdSql.query("select distinct t0, t1 from stb1 where t1 > 3 limit 2")
|
tdSql.query(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3 limit 2")
|
||||||
# tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
# tdSql.query("select distinct t0, t1 from stb1 where t1 > 3 limit 2 offset 2")
|
tdSql.query(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3 limit 2 offset 2")
|
||||||
# tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
# tdSql.query("select distinct t0, t1 from stb1 where t1 > 3 slimit 2")
|
tdSql.error(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3 slimit 2")
|
||||||
# tdSql.checkRows(3)
|
tdSql.query(f"select distinct t0, t1 from {dbname}.stb1 where c1 > 2")
|
||||||
# tdSql.error("select distinct t0, t1 from stb1 where c1 > 2")
|
tdSql.query(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3 and t1 < 5")
|
||||||
# tdSql.query("select distinct t0, t1 from stb1 where t1 > 3 and t1 < 5")
|
tdSql.checkRows(1)
|
||||||
# tdSql.checkRows(1)
|
tdSql.error(f"select distinct stb1.t0, stb1.t1 from {dbname}.stb1, {dbname}.stb2 where stb1.t2=stb2.t4")
|
||||||
# tdSql.error("select distinct stb1.t0, stb1.t1 from stb1, stb2 where stb1.t2=stb2.t4")
|
tdSql.error(f"select distinct t0, t1 from {dbname}.stb1 where stb2.t4 > 2")
|
||||||
# tdSql.error("select distinct t0, t1 from stb1 where stb2.t4 > 2")
|
tdSql.error(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3 group by t0")
|
||||||
# tdSql.error("select distinct t0, t1 from stb1 where t1 > 3 group by t0")
|
tdSql.error(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3 interval(1d) ")
|
||||||
# tdSql.error("select distinct t0, t1 from stb1 where t1 > 3 interval(1d) ")
|
tdSql.error(f"select distinct t0, t1 from {dbname}.stb1 where t1 > 3 interval(1d) fill(next)")
|
||||||
# tdSql.error("select distinct t0, t1 from stb1 where t1 > 3 interval(1d) fill(next)")
|
tdSql.error(f"select distinct t0, t1 from {dbname}.stb1 where ts > now-10d and ts < now interval(1d) fill(next)")
|
||||||
# tdSql.error("select distinct t0, t1 from stb1 where ts > now-10d and ts < now interval(1d) fill(next)")
|
|
||||||
|
|
||||||
# tdSql.error("select max(c1), distinct t0 from stb1 where t0 > 2")
|
tdSql.error(f"select max(c1), distinct t0 from {dbname}.stb1 where t0 > 2")
|
||||||
# tdSql.error("select distinct t0, max(c1) from stb1 where t0 > 2")
|
tdSql.query(f"select distinct t0, max(c1) from {dbname}.stb1 where t0 > 2")
|
||||||
# tdSql.error("select distinct t0 from stb1 where t0 in (select t0 from stb1 where t0 > 2)")
|
tdSql.error(f"select distinct t0 from {dbname}.stb1 where t0 in (select t0 from {dbname}.stb1 where t0 > 2)")
|
||||||
# tdSql.query("select distinct t0, t1 from stb1 where t0 in (1,2,3,4,5)")
|
tdSql.query(f"select distinct t0, t1 from {dbname}.stb1 where t0 in (1,2,3,4,5)")
|
||||||
# tdSql.checkRows(5)
|
tdSql.checkRows(5)
|
||||||
# tdSql.query("select distinct t1 from (select t0, t1 from stb1 where t0 > 2) ")
|
tdSql.query(f"select distinct t1 from (select t0, t1 from {dbname}.stb1 where t0 > 2) ")
|
||||||
# tdSql.checkRows(4)
|
tdSql.checkRows(4)
|
||||||
# tdSql.error("select distinct t1 from (select distinct t0, t1 from stb1 where t0 > 2 and t1 < 3) ")
|
tdSql.query(f"select distinct t1 from (select distinct t0, t1 from {dbname}.stb1 where t0 > 2 and t1 < 3) ")
|
||||||
# tdSql.error("select distinct t1 from (select distinct t0, t1 from stb1 where t0 > 2 ) where t1 < 3")
|
# TODO: BUG of TD-17561
|
||||||
# tdSql.query("select distinct t1 from (select t0, t1 from stb1 where t0 > 2 ) where t1 < 3")
|
# tdSql.query(f"select distinct t1 from (select distinct t0, t1 from {dbname}.stb1 where t0 > 2 ) where t1 < 3")
|
||||||
# tdSql.checkRows(1)
|
tdSql.query(f"select distinct t1 from (select t0, t1 from {dbname}.stb1 where t0 > 2 ) where t1 < 3")
|
||||||
# tdSql.error("select distinct t1, t0 from (select t1 from stb1 where t0 > 2 ) where t1 < 3")
|
tdSql.checkRows(1)
|
||||||
# tdSql.error("select distinct t1, t0 from (select max(t1) t1, max(t0) t0 from stb1 group by t1)")
|
tdSql.error(f"select distinct t1, t0 from (select t1 from {dbname}.stb1 where t0 > 2 ) where t1 < 3")
|
||||||
# tdSql.error("select distinct t1, t0 from (select max(t1) t1, max(t0) t0 from stb1)")
|
tdSql.query(f"select distinct t1, t0 from (select max(t1) t1, max(t0) t0 from {dbname}.stb1 group by t1)")
|
||||||
# tdSql.query("select distinct t1, t0 from (select t1,t0 from stb1 where t0 > 2 ) where t1 < 3")
|
tdSql.query(f"select distinct t1, t0 from (select max(t1) t1, max(t0) t0 from {dbname}.stb1)")
|
||||||
# tdSql.checkRows(1)
|
tdSql.query(f"select distinct t1, t0 from (select t1,t0 from {dbname}.stb1 where t0 > 2 ) where t1 < 3")
|
||||||
# tdSql.error(" select distinct t1, t0 from (select t1,t0 from stb1 where t0 > 2 order by ts) where t1 < 3")
|
tdSql.checkRows(1)
|
||||||
# tdSql.error("select t1, t0 from (select distinct t1,t0 from stb1 where t0 > 2 ) where t1 < 3")
|
tdSql.query(f"select distinct t1, t0 from (select t1,t0 from {dbname}.stb1 where t0 > 2 order by ts) where t1 < 3")
|
||||||
# tdSql.error(" select distinct t1, t0 from (select t1,t0 from stb1 where t0 > 2 group by ts) where t1 < 3")
|
# TODO: BUG of TD-17561
|
||||||
# tdSql.error("select distinct stb1.t1, stb1.t2 from stb1 , stb2 where stb1.ts=stb2.ts and stb1.t2=stb2.t4")
|
# tdSql.error(f"select t1, t0 from (select distinct t1,t0 from {dbname}.stb1 where t0 > 2 ) where t1 < 3")
|
||||||
# tdSql.error("select distinct t1.t1, t1.t2 from t1 , t2 where t1.ts=t2.ts ")
|
tdSql.error(f"select distinct t1, t0 from (select t1,t0 from {dbname}.stb1 where t0 > 2 group by ts) where t1 < 3")
|
||||||
|
tdSql.query(f"select distinct stb1.t1, stb1.t2 from {dbname}.stb1, {dbname}.stb2 where stb1.ts=stb2.ts and stb1.t2=stb2.t4")
|
||||||
|
tdSql.query(f"select distinct t1.t1, t1.t2 from {dbname}.t1, {dbname}.t2 where t1.ts=t2.ts ")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,86 +6,60 @@ import random
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
|
|
||||||
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
|
|
||||||
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143,
|
|
||||||
"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
|
|
||||||
|
|
||||||
|
updatecfgDict = {"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
|
||||||
def init(self, conn, logSql):
|
def init(self, conn, logSql):
|
||||||
tdLog.debug("start to execute %s" % __file__)
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
tdSql.init(conn.cursor())
|
tdSql.init(conn.cursor())
|
||||||
self.vnode_disbutes = None
|
self.vnode_disbutes = None
|
||||||
self.ts = 1537146000000
|
self.ts = 1537146000000
|
||||||
|
|
||||||
def prepare_datas_of_distribute(self):
|
def prepare_datas_of_distribute(self, dbname="testdb"):
|
||||||
|
|
||||||
# prepate datas for 20 tables distributed at different vgroups
|
# prepate datas for 20 tables distributed at different vgroups
|
||||||
tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5")
|
tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5")
|
||||||
tdSql.execute(" use testdb ")
|
tdSql.execute(f" use {dbname} ")
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
'''create table stb1
|
f'''create table {dbname}.stb1
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||||
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
|
||||||
'''
|
|
||||||
create table t1
|
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
|
||||||
'''
|
|
||||||
)
|
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in range(1,21):
|
for i in range(1,21):
|
||||||
if i ==1 or i == 4:
|
if i ==1 or i == 4:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
tbname = "ct"+f'{i}'
|
tbname = f"{dbname}.ct{i}"
|
||||||
for j in range(9):
|
for j in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )"
|
f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )"
|
||||||
)
|
)
|
||||||
tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
|
|
||||||
tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
|
|
||||||
tdSql.execute(
|
|
||||||
f'''insert into t1 values
|
|
||||||
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
|
||||||
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
|
|
||||||
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
|
||||||
( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a )
|
|
||||||
( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a )
|
|
||||||
( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
|
||||||
( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a )
|
|
||||||
( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a )
|
|
||||||
( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
|
|
||||||
( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
|
|
||||||
( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
|
|
||||||
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
|
||||||
'''
|
|
||||||
)
|
|
||||||
|
|
||||||
tdLog.info(" prepare data for distributed_aggregate done! ")
|
tdLog.info(" prepare data for distributed_aggregate done! ")
|
||||||
|
|
||||||
def check_distribute_datas(self):
|
def check_distribute_datas(self, dbname="testdb"):
|
||||||
# get vgroup_ids of all
|
# get vgroup_ids of all
|
||||||
tdSql.query("show vgroups ")
|
tdSql.query(f"show {dbname}.vgroups ")
|
||||||
vgroups = tdSql.queryResult
|
vgroups = tdSql.queryResult
|
||||||
|
|
||||||
vnode_tables={}
|
vnode_tables={}
|
||||||
|
@ -95,7 +69,7 @@ class TDTestCase:
|
||||||
|
|
||||||
|
|
||||||
# check sub_table of per vnode ,make sure sub_table has been distributed
|
# check sub_table of per vnode ,make sure sub_table has been distributed
|
||||||
tdSql.query("show tables like 'ct%'")
|
tdSql.query(f"show {dbname}.tables like 'ct%'")
|
||||||
table_names = tdSql.queryResult
|
table_names = tdSql.queryResult
|
||||||
tablenames = []
|
tablenames = []
|
||||||
for table_name in table_names:
|
for table_name in table_names:
|
||||||
|
@ -109,28 +83,28 @@ class TDTestCase:
|
||||||
if count < 2:
|
if count < 2:
|
||||||
tdLog.exit(" the datas of all not satisfy sub_table has been distributed ")
|
tdLog.exit(" the datas of all not satisfy sub_table has been distributed ")
|
||||||
|
|
||||||
def distribute_agg_query(self):
|
def distribute_agg_query(self, dbname="testdb"):
|
||||||
# basic filter
|
# basic filter
|
||||||
tdSql.query("select apercentile(c1 , 20) from stb1 where c1 is null")
|
tdSql.query(f"select apercentile(c1 , 20) from {dbname}.stb1 where c1 is null")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
tdSql.query("select apercentile(c1 , 20) from stb1 where t1=1")
|
tdSql.query(f"select apercentile(c1 , 20) from {dbname}.stb1 where t1=1")
|
||||||
tdSql.checkData(0,0,2.800000000)
|
tdSql.checkData(0,0,2.800000000)
|
||||||
|
|
||||||
tdSql.query("select apercentile(c1+c2 ,100) from stb1 where c1 =1 ")
|
tdSql.query(f"select apercentile(c1+c2 ,100) from {dbname}.stb1 where c1 =1 ")
|
||||||
tdSql.checkData(0,0,11112.000000000)
|
tdSql.checkData(0,0,11112.000000000)
|
||||||
|
|
||||||
tdSql.query("select apercentile(c1 ,10 ) from stb1 where tbname=\"ct2\"")
|
tdSql.query(f"select apercentile(c1 ,10 ) from {dbname}.stb1 where tbname=\"ct2\"")
|
||||||
tdSql.checkData(0,0,2.000000000)
|
tdSql.checkData(0,0,2.000000000)
|
||||||
|
|
||||||
tdSql.query("select apercentile(c1,20) from stb1 partition by tbname")
|
tdSql.query(f"select apercentile(c1,20) from {dbname}.stb1 partition by tbname")
|
||||||
tdSql.checkRows(20)
|
tdSql.checkRows(20)
|
||||||
|
|
||||||
tdSql.query("select apercentile(c1,20) from stb1 where t1> 4 partition by tbname")
|
tdSql.query(f"select apercentile(c1,20) from {dbname}.stb1 where t1> 4 partition by tbname")
|
||||||
tdSql.checkRows(15)
|
tdSql.checkRows(15)
|
||||||
|
|
||||||
# union all
|
# union all
|
||||||
tdSql.query("select apercentile(c1,20) from stb1 union all select apercentile(c1,20) from stb1 ")
|
tdSql.query(f"select apercentile(c1,20) from {dbname}.stb1 union all select apercentile(c1,20) from {dbname}.stb1 ")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0,0,7.389181281)
|
tdSql.checkData(0,0,7.389181281)
|
||||||
|
|
||||||
|
@ -138,44 +112,44 @@ class TDTestCase:
|
||||||
|
|
||||||
tdSql.execute(" create database if not exists db ")
|
tdSql.execute(" create database if not exists db ")
|
||||||
tdSql.execute(" use db ")
|
tdSql.execute(" use db ")
|
||||||
tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ")
|
tdSql.execute(" create stable db.st (ts timestamp , c1 int ,c2 float) tags(t1 int) ")
|
||||||
tdSql.execute(" create table tb1 using st tags(1) ")
|
tdSql.execute(" create table db.tb1 using db.st tags(1) ")
|
||||||
tdSql.execute(" create table tb2 using st tags(2) ")
|
tdSql.execute(" create table db.tb2 using db.st tags(2) ")
|
||||||
|
|
||||||
|
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
ts = i*10 + self.ts
|
ts = i*10 + self.ts
|
||||||
tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)")
|
tdSql.execute(f" insert into db.tb1 values({ts},{i},{i}.0)")
|
||||||
tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)")
|
tdSql.execute(f" insert into db.tb2 values({ts},{i},{i}.0)")
|
||||||
|
|
||||||
tdSql.query("select apercentile(tb1.c1,100), apercentile(tb2.c2,100) from tb1, tb2 where tb1.ts=tb2.ts")
|
tdSql.query(f"select apercentile(tb1.c1,100), apercentile(tb2.c2,100) from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,9.000000000)
|
tdSql.checkData(0,0,9.000000000)
|
||||||
tdSql.checkData(0,0,9.000000000)
|
tdSql.checkData(0,0,9.000000000)
|
||||||
|
|
||||||
# group by
|
# group by
|
||||||
tdSql.execute(" use testdb ")
|
tdSql.execute(f"use {dbname} ")
|
||||||
tdSql.query(" select max(c1),c1 from stb1 group by t1 ")
|
tdSql.query(f" select max(c1),c1 from {dbname}.stb1 group by t1 ")
|
||||||
tdSql.checkRows(20)
|
tdSql.checkRows(20)
|
||||||
tdSql.query(" select max(c1),c1 from stb1 group by c1 ")
|
tdSql.query(f" select max(c1),c1 from {dbname}.stb1 group by c1 ")
|
||||||
tdSql.checkRows(30)
|
tdSql.checkRows(30)
|
||||||
tdSql.query(" select max(c1),c2 from stb1 group by c2 ")
|
tdSql.query(f" select max(c1),c2 from {dbname}.stb1 group by c2 ")
|
||||||
tdSql.checkRows(31)
|
tdSql.checkRows(31)
|
||||||
|
|
||||||
# partition by tbname or partition by tag
|
# partition by tbname or partition by tag
|
||||||
tdSql.query("select apercentile(c1 ,10)from stb1 partition by tbname")
|
tdSql.query(f"select apercentile(c1 ,10)from {dbname}.stb1 partition by tbname")
|
||||||
query_data = tdSql.queryResult
|
query_data = tdSql.queryResult
|
||||||
|
|
||||||
# nest query for support max
|
# nest query for support max
|
||||||
tdSql.query("select apercentile(c2+2,10)+1 from (select max(c1) c2 from stb1)")
|
tdSql.query(f"select apercentile(c2+2,10)+1 from (select max(c1) c2 from {dbname}.stb1)")
|
||||||
tdSql.checkData(0,0,31.000000000)
|
tdSql.checkData(0,0,31.000000000)
|
||||||
tdSql.query("select apercentile(c1+2,10)+1 as c2 from (select ts ,c1 ,c2 from stb1)")
|
tdSql.query(f"select apercentile(c1+2,10)+1 as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)")
|
||||||
tdSql.checkData(0,0,7.560701700)
|
tdSql.checkData(0,0,7.560701700)
|
||||||
tdSql.query("select apercentile(a+2,10)+1 as c2 from (select ts ,abs(c1) a ,c2 from stb1)")
|
tdSql.query(f"select apercentile(a+2,10)+1 as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)")
|
||||||
tdSql.checkData(0,0,7.560701700)
|
tdSql.checkData(0,0,7.560701700)
|
||||||
|
|
||||||
# mixup with other functions
|
# mixup with other functions
|
||||||
tdSql.query("select max(c1),count(c1),last(c2,c3),spread(c1), apercentile(c1,10) from stb1")
|
tdSql.query(f"select max(c1),count(c1),last(c2,c3),spread(c1), apercentile(c1,10) from {dbname}.stb1")
|
||||||
tdSql.checkData(0,0,28)
|
tdSql.checkData(0,0,28)
|
||||||
tdSql.checkData(0,1,184)
|
tdSql.checkData(0,1,184)
|
||||||
tdSql.checkData(0,2,-99999)
|
tdSql.checkData(0,2,-99999)
|
||||||
|
|
|
@ -7,11 +7,8 @@ import platform
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
|
|
||||||
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
|
|
||||||
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143,
|
|
||||||
"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
|
|
||||||
|
|
||||||
|
updatecfgDict = {"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
|
||||||
def init(self, conn, logSql):
|
def init(self, conn, logSql):
|
||||||
tdLog.debug("start to execute %s" % __file__)
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
tdSql.init(conn.cursor())
|
tdSql.init(conn.cursor())
|
||||||
|
@ -34,75 +31,52 @@ class TDTestCase:
|
||||||
tdSql.query(avg_sql)
|
tdSql.query(avg_sql)
|
||||||
tdSql.checkData(0,0,pre_avg)
|
tdSql.checkData(0,0,pre_avg)
|
||||||
|
|
||||||
def prepare_datas_of_distribute(self):
|
def prepare_datas_of_distribute(self, dbname="testdb"):
|
||||||
|
|
||||||
# prepate datas for 20 tables distributed at different vgroups
|
# prepate datas for 20 tables distributed at different vgroups
|
||||||
tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5")
|
tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5")
|
||||||
tdSql.execute(" use testdb ")
|
tdSql.execute(f" use {dbname} ")
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
'''create table stb1
|
f'''create table {dbname}.stb1
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||||
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
|
||||||
'''
|
|
||||||
create table t1
|
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
|
||||||
'''
|
|
||||||
)
|
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in range(1,21):
|
for i in range(1,21):
|
||||||
if i ==1 or i == 4:
|
if i ==1 or i == 4:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
tbname = "ct"+f'{i}'
|
tbname = f"{dbname}.ct{i}"
|
||||||
for j in range(9):
|
for j in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )"
|
f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )"
|
||||||
)
|
)
|
||||||
tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
|
|
||||||
tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
|
|
||||||
tdSql.execute(
|
|
||||||
f'''insert into t1 values
|
|
||||||
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
|
||||||
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
|
|
||||||
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
|
||||||
( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a )
|
|
||||||
( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a )
|
|
||||||
( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
|
||||||
( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a )
|
|
||||||
( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a )
|
|
||||||
( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
|
|
||||||
( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
|
|
||||||
( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
|
|
||||||
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
|
||||||
'''
|
|
||||||
)
|
|
||||||
|
|
||||||
tdLog.info(" prepare data for distributed_aggregate done! ")
|
tdLog.info(" prepare data for distributed_aggregate done! ")
|
||||||
|
|
||||||
def check_distribute_datas(self):
|
def check_distribute_datas(self, dbname="testdb"):
|
||||||
# get vgroup_ids of all
|
# get vgroup_ids of all
|
||||||
tdSql.query("show vgroups ")
|
tdSql.query(f"show {dbname}.vgroups ")
|
||||||
vgroups = tdSql.queryResult
|
vgroups = tdSql.queryResult
|
||||||
|
|
||||||
vnode_tables={}
|
vnode_tables={}
|
||||||
|
@ -112,7 +86,7 @@ class TDTestCase:
|
||||||
|
|
||||||
|
|
||||||
# check sub_table of per vnode ,make sure sub_table has been distributed
|
# check sub_table of per vnode ,make sure sub_table has been distributed
|
||||||
tdSql.query("show tables like 'ct%'")
|
tdSql.query(f"show {dbname}.tables like 'ct%'")
|
||||||
table_names = tdSql.queryResult
|
table_names = tdSql.queryResult
|
||||||
tablenames = []
|
tablenames = []
|
||||||
for table_name in table_names:
|
for table_name in table_names:
|
||||||
|
@ -126,7 +100,7 @@ class TDTestCase:
|
||||||
if count < 2:
|
if count < 2:
|
||||||
tdLog.exit(" the datas of all not satisfy sub_table has been distributed ")
|
tdLog.exit(" the datas of all not satisfy sub_table has been distributed ")
|
||||||
|
|
||||||
def check_avg_distribute_diff_vnode(self,col_name):
|
def check_avg_distribute_diff_vnode(self,col_name, dbname="testdb"):
|
||||||
|
|
||||||
vgroup_ids = []
|
vgroup_ids = []
|
||||||
for k ,v in self.vnode_disbutes.items():
|
for k ,v in self.vnode_disbutes.items():
|
||||||
|
@ -144,9 +118,9 @@ class TDTestCase:
|
||||||
|
|
||||||
tbname_filters = tbname_ins[:-1]
|
tbname_filters = tbname_ins[:-1]
|
||||||
|
|
||||||
avg_sql = f"select avg({col_name}) from stb1 where tbname in ({tbname_filters});"
|
avg_sql = f"select avg({col_name}) from {dbname}.stb1 where tbname in ({tbname_filters});"
|
||||||
|
|
||||||
same_sql = f"select {col_name} from stb1 where tbname in ({tbname_filters}) and {col_name} is not null "
|
same_sql = f"select {col_name} from {dbname}.stb1 where tbname in ({tbname_filters}) and {col_name} is not null "
|
||||||
|
|
||||||
tdSql.query(same_sql)
|
tdSql.query(same_sql)
|
||||||
pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None]
|
pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None]
|
||||||
|
@ -157,16 +131,16 @@ class TDTestCase:
|
||||||
tdSql.query(avg_sql)
|
tdSql.query(avg_sql)
|
||||||
tdSql.checkData(0,0,pre_avg)
|
tdSql.checkData(0,0,pre_avg)
|
||||||
|
|
||||||
def check_avg_status(self):
|
def check_avg_status(self, dbname="testdb"):
|
||||||
# check max function work status
|
# check max function work status
|
||||||
|
|
||||||
tdSql.query("show tables like 'ct%'")
|
tdSql.query(f"show {dbname}.tables like 'ct%'")
|
||||||
table_names = tdSql.queryResult
|
table_names = tdSql.queryResult
|
||||||
tablenames = []
|
tablenames = []
|
||||||
for table_name in table_names:
|
for table_name in table_names:
|
||||||
tablenames.append(table_name[0])
|
tablenames.append(f"{dbname}.{table_name[0]}")
|
||||||
|
|
||||||
tdSql.query("desc stb1")
|
tdSql.query(f"desc {dbname}.stb1")
|
||||||
col_names = tdSql.queryResult
|
col_names = tdSql.queryResult
|
||||||
|
|
||||||
colnames = []
|
colnames = []
|
||||||
|
@ -182,41 +156,41 @@ class TDTestCase:
|
||||||
|
|
||||||
for colname in colnames:
|
for colname in colnames:
|
||||||
if colname.startswith("c"):
|
if colname.startswith("c"):
|
||||||
self.check_avg_distribute_diff_vnode(colname)
|
self.check_avg_distribute_diff_vnode(colname, dbname)
|
||||||
else:
|
else:
|
||||||
# self.check_avg_distribute_diff_vnode(colname) # bug for tag
|
# self.check_avg_distribute_diff_vnode(colname, dbname) # bug for tag
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def distribute_agg_query(self):
|
def distribute_agg_query(self, dbname="testdb"):
|
||||||
# basic filter
|
# basic filter
|
||||||
tdSql.query(" select avg(c1) from stb1 ")
|
tdSql.query(f"select avg(c1) from {dbname}.stb1 ")
|
||||||
tdSql.checkData(0,0,14.086956522)
|
tdSql.checkData(0,0,14.086956522)
|
||||||
|
|
||||||
tdSql.query(" select avg(a) from (select avg(c1) a from stb1 partition by tbname) ")
|
tdSql.query(f"select avg(a) from (select avg(c1) a from {dbname}.stb1 partition by tbname) ")
|
||||||
tdSql.checkData(0,0,14.292307692)
|
tdSql.checkData(0,0,14.292307692)
|
||||||
|
|
||||||
tdSql.query(" select avg(c1) from stb1 where t1=1")
|
tdSql.query(f"select avg(c1) from {dbname}.stb1 where t1=1")
|
||||||
tdSql.checkData(0,0,6.000000000)
|
tdSql.checkData(0,0,6.000000000)
|
||||||
|
|
||||||
tdSql.query("select avg(c1+c2) from stb1 where c1 =1 ")
|
tdSql.query(f"select avg(c1+c2) from {dbname}.stb1 where c1 =1 ")
|
||||||
tdSql.checkData(0,0,11112.000000000)
|
tdSql.checkData(0,0,11112.000000000)
|
||||||
|
|
||||||
tdSql.query("select avg(c1) from stb1 where tbname=\"ct2\"")
|
tdSql.query(f"select avg(c1) from {dbname}.stb1 where tbname=\"ct2\"")
|
||||||
tdSql.checkData(0,0,6.000000000)
|
tdSql.checkData(0,0,6.000000000)
|
||||||
|
|
||||||
tdSql.query("select avg(c1) from stb1 partition by tbname")
|
tdSql.query(f"select avg(c1) from {dbname}.stb1 partition by tbname")
|
||||||
tdSql.checkRows(20)
|
tdSql.checkRows(20)
|
||||||
|
|
||||||
tdSql.query("select avg(c1) from stb1 where t1> 4 partition by tbname")
|
tdSql.query(f"select avg(c1) from {dbname}.stb1 where t1> 4 partition by tbname")
|
||||||
tdSql.checkRows(15)
|
tdSql.checkRows(15)
|
||||||
|
|
||||||
# union all
|
# union all
|
||||||
tdSql.query("select avg(c1) from stb1 union all select avg(c1) from stb1 ")
|
tdSql.query(f"select avg(c1) from {dbname}.stb1 union all select avg(c1) from {dbname}.stb1 ")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0,0,14.086956522)
|
tdSql.checkData(0,0,14.086956522)
|
||||||
|
|
||||||
tdSql.query("select avg(a) from (select avg(c1) a from stb1 union all select avg(c1) a from stb1)")
|
tdSql.query(f"select avg(a) from (select avg(c1) a from {dbname}.stb1 union all select avg(c1) a from {dbname}.stb1)")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,14.086956522)
|
tdSql.checkData(0,0,14.086956522)
|
||||||
|
|
||||||
|
@ -224,38 +198,38 @@ class TDTestCase:
|
||||||
|
|
||||||
tdSql.execute(" create database if not exists db ")
|
tdSql.execute(" create database if not exists db ")
|
||||||
tdSql.execute(" use db ")
|
tdSql.execute(" use db ")
|
||||||
tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ")
|
tdSql.execute(" create stable db.st (ts timestamp , c1 int ,c2 float) tags(t1 int) ")
|
||||||
tdSql.execute(" create table tb1 using st tags(1) ")
|
tdSql.execute(" create table db.tb1 using db.st tags(1) ")
|
||||||
tdSql.execute(" create table tb2 using st tags(2) ")
|
tdSql.execute(" create table db.tb2 using db.st tags(2) ")
|
||||||
|
|
||||||
|
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
ts = i*10 + self.ts
|
ts = i*10 + self.ts
|
||||||
tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)")
|
tdSql.execute(f" insert into db.tb1 values({ts},{i},{i}.0)")
|
||||||
tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)")
|
tdSql.execute(f" insert into db.tb2 values({ts},{i},{i}.0)")
|
||||||
|
|
||||||
tdSql.query("select avg(tb1.c1), avg(tb2.c2) from tb1, tb2 where tb1.ts=tb2.ts")
|
tdSql.query(f"select avg(tb1.c1), avg(tb2.c2) from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,4.500000000)
|
tdSql.checkData(0,0,4.500000000)
|
||||||
tdSql.checkData(0,1,4.500000000)
|
tdSql.checkData(0,1,4.500000000)
|
||||||
|
|
||||||
# group by
|
# group by
|
||||||
tdSql.execute(" use testdb ")
|
tdSql.execute(f" use {dbname} ")
|
||||||
|
|
||||||
# partition by tbname or partition by tag
|
# partition by tbname or partition by tag
|
||||||
tdSql.query("select avg(c1) from stb1 partition by tbname")
|
tdSql.query(f"select avg(c1) from {dbname}.stb1 partition by tbname")
|
||||||
tdSql.checkRows(20)
|
tdSql.checkRows(20)
|
||||||
|
|
||||||
# nest query for support max
|
# nest query for support max
|
||||||
tdSql.query("select avg(c2+2)+1 from (select avg(c1) c2 from stb1)")
|
tdSql.query(f"select avg(c2+2)+1 from (select avg(c1) c2 from {dbname}.stb1)")
|
||||||
tdSql.checkData(0,0,17.086956522)
|
tdSql.checkData(0,0,17.086956522)
|
||||||
tdSql.query("select avg(c1+2) as c2 from (select ts ,c1 ,c2 from stb1)")
|
tdSql.query(f"select avg(c1+2) as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)")
|
||||||
tdSql.checkData(0,0,16.086956522)
|
tdSql.checkData(0,0,16.086956522)
|
||||||
tdSql.query("select avg(a+2) as c2 from (select ts ,abs(c1) a ,c2 from stb1)")
|
tdSql.query(f"select avg(a+2) as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)")
|
||||||
tdSql.checkData(0,0,16.086956522)
|
tdSql.checkData(0,0,16.086956522)
|
||||||
|
|
||||||
# mixup with other functions
|
# mixup with other functions
|
||||||
tdSql.query("select max(c1),count(c1),last(c2,c3),sum(c1+c2),avg(c1) from stb1")
|
tdSql.query(f"select max(c1),count(c1),last(c2,c3),sum(c1+c2),avg(c1) from {dbname}.stb1")
|
||||||
tdSql.checkData(0,0,28)
|
tdSql.checkData(0,0,28)
|
||||||
tdSql.checkData(0,1,184)
|
tdSql.checkData(0,1,184)
|
||||||
tdSql.checkData(0,2,-99999)
|
tdSql.checkData(0,2,-99999)
|
||||||
|
|
|
@ -6,11 +6,8 @@ import random
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
|
|
||||||
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
|
|
||||||
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143,
|
|
||||||
"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
|
|
||||||
|
|
||||||
|
updatecfgDict = {"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
|
||||||
def init(self, conn, logSql):
|
def init(self, conn, logSql):
|
||||||
tdLog.debug("start to execute %s" % __file__)
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
tdSql.init(conn.cursor())
|
tdSql.init(conn.cursor())
|
||||||
|
@ -35,76 +32,52 @@ class TDTestCase:
|
||||||
else:
|
else:
|
||||||
tdLog.info(" count function work as expected, sql : %s "% max_sql)
|
tdLog.info(" count function work as expected, sql : %s "% max_sql)
|
||||||
|
|
||||||
|
def prepare_datas_of_distribute(self, dbname="testdb"):
|
||||||
def prepare_datas_of_distribute(self):
|
|
||||||
|
|
||||||
# prepate datas for 20 tables distributed at different vgroups
|
# prepate datas for 20 tables distributed at different vgroups
|
||||||
tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5")
|
tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5")
|
||||||
tdSql.execute(" use testdb ")
|
tdSql.execute(f" use {dbname} ")
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
'''create table stb1
|
f'''create table {dbname}.stb1
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||||
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
|
||||||
'''
|
|
||||||
create table t1
|
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
|
||||||
'''
|
|
||||||
)
|
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in range(1,21):
|
for i in range(1,21):
|
||||||
if i ==1 or i == 4:
|
if i ==1 or i == 4:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
tbname = "ct"+f'{i}'
|
tbname = f"{dbname}.ct{i}"
|
||||||
for j in range(9):
|
for j in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )"
|
f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )"
|
||||||
)
|
)
|
||||||
tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
|
|
||||||
tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
|
|
||||||
tdSql.execute(
|
|
||||||
f'''insert into t1 values
|
|
||||||
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
|
||||||
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
|
|
||||||
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
|
||||||
( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a )
|
|
||||||
( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a )
|
|
||||||
( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
|
||||||
( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a )
|
|
||||||
( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a )
|
|
||||||
( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
|
|
||||||
( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
|
|
||||||
( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
|
|
||||||
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
|
||||||
'''
|
|
||||||
)
|
|
||||||
|
|
||||||
tdLog.info(" prepare data for distributed_aggregate done! ")
|
tdLog.info(" prepare data for distributed_aggregate done! ")
|
||||||
|
|
||||||
def check_distribute_datas(self):
|
def check_distribute_datas(self, dbname="testdb"):
|
||||||
# get vgroup_ids of all
|
# get vgroup_ids of all
|
||||||
tdSql.query("show vgroups ")
|
tdSql.query(f"show {dbname}.vgroups ")
|
||||||
vgroups = tdSql.queryResult
|
vgroups = tdSql.queryResult
|
||||||
|
|
||||||
vnode_tables={}
|
vnode_tables={}
|
||||||
|
@ -114,7 +87,7 @@ class TDTestCase:
|
||||||
|
|
||||||
|
|
||||||
# check sub_table of per vnode ,make sure sub_table has been distributed
|
# check sub_table of per vnode ,make sure sub_table has been distributed
|
||||||
tdSql.query("show tables like 'ct%'")
|
tdSql.query(f"show {dbname}.tables like 'ct%'")
|
||||||
table_names = tdSql.queryResult
|
table_names = tdSql.queryResult
|
||||||
tablenames = []
|
tablenames = []
|
||||||
for table_name in table_names:
|
for table_name in table_names:
|
||||||
|
@ -128,7 +101,7 @@ class TDTestCase:
|
||||||
if count < 2:
|
if count < 2:
|
||||||
tdLog.exit(" the datas of all not satisfy sub_table has been distributed ")
|
tdLog.exit(" the datas of all not satisfy sub_table has been distributed ")
|
||||||
|
|
||||||
def check_count_distribute_diff_vnode(self,col_name):
|
def check_count_distribute_diff_vnode(self,col_name, dbname="testdb"):
|
||||||
|
|
||||||
vgroup_ids = []
|
vgroup_ids = []
|
||||||
for k ,v in self.vnode_disbutes.items():
|
for k ,v in self.vnode_disbutes.items():
|
||||||
|
@ -146,9 +119,9 @@ class TDTestCase:
|
||||||
|
|
||||||
tbname_filters = tbname_ins[:-1]
|
tbname_filters = tbname_ins[:-1]
|
||||||
|
|
||||||
max_sql = f"select count({col_name}) from stb1 where tbname in ({tbname_filters});"
|
max_sql = f"select count({col_name}) from {dbname}.stb1 where tbname in ({tbname_filters});"
|
||||||
|
|
||||||
same_sql = f"select sum(c) from (select {col_name} ,1 as c from stb1 where tbname in ({tbname_filters}) and {col_name} is not null) "
|
same_sql = f"select sum(c) from (select {col_name} ,1 as c from {dbname}.stb1 where tbname in ({tbname_filters}) and {col_name} is not null) "
|
||||||
|
|
||||||
tdSql.query(max_sql)
|
tdSql.query(max_sql)
|
||||||
max_result = tdSql.queryResult
|
max_result = tdSql.queryResult
|
||||||
|
@ -161,16 +134,16 @@ class TDTestCase:
|
||||||
else:
|
else:
|
||||||
tdLog.info(" count function work as expected, sql : %s "% max_sql)
|
tdLog.info(" count function work as expected, sql : %s "% max_sql)
|
||||||
|
|
||||||
def check_count_status(self):
|
def check_count_status(self, dbname="testdb"):
|
||||||
# check max function work status
|
# check max function work status
|
||||||
|
|
||||||
tdSql.query("show tables like 'ct%'")
|
tdSql.query(f"show {dbname}.tables like 'ct%'")
|
||||||
table_names = tdSql.queryResult
|
table_names = tdSql.queryResult
|
||||||
tablenames = []
|
tablenames = []
|
||||||
for table_name in table_names:
|
for table_name in table_names:
|
||||||
tablenames.append(table_name[0])
|
tablenames.append(f"{dbname}.{table_name[0]}")
|
||||||
|
|
||||||
tdSql.query("desc stb1")
|
tdSql.query(f"desc {dbname}.stb1")
|
||||||
col_names = tdSql.queryResult
|
col_names = tdSql.queryResult
|
||||||
|
|
||||||
colnames = []
|
colnames = []
|
||||||
|
@ -186,34 +159,33 @@ class TDTestCase:
|
||||||
|
|
||||||
for colname in colnames:
|
for colname in colnames:
|
||||||
if colname.startswith("c"):
|
if colname.startswith("c"):
|
||||||
self.check_count_distribute_diff_vnode(colname)
|
self.check_count_distribute_diff_vnode(colname, dbname)
|
||||||
else:
|
else:
|
||||||
# self.check_count_distribute_diff_vnode(colname) # bug for tag
|
# self.check_count_distribute_diff_vnode(colname, dbname) # bug for tag
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def distribute_agg_query(self, dbname="testdb"):
|
||||||
def distribute_agg_query(self):
|
|
||||||
# basic filter
|
# basic filter
|
||||||
tdSql.query("select count(c1) from stb1 ")
|
tdSql.query(f"select count(c1) from {dbname}.stb1 ")
|
||||||
tdSql.checkData(0,0,184)
|
tdSql.checkData(0,0,184)
|
||||||
|
|
||||||
tdSql.query("select count(c1) from stb1 where t1=1")
|
tdSql.query(f"select count(c1) from {dbname}.stb1 where t1=1")
|
||||||
tdSql.checkData(0,0,9)
|
tdSql.checkData(0,0,9)
|
||||||
|
|
||||||
tdSql.query("select count(c1+c2) from stb1 where c1 =1 ")
|
tdSql.query(f"select count(c1+c2) from {dbname}.stb1 where c1 =1 ")
|
||||||
tdSql.checkData(0,0,2)
|
tdSql.checkData(0,0,2)
|
||||||
|
|
||||||
tdSql.query("select count(c1) from stb1 where tbname=\"ct2\"")
|
tdSql.query(f"select count(c1) from {dbname}.stb1 where tbname=\"ct2\"")
|
||||||
tdSql.checkData(0,0,9)
|
tdSql.checkData(0,0,9)
|
||||||
|
|
||||||
tdSql.query("select count(c1) from stb1 partition by tbname")
|
tdSql.query(f"select count(c1) from {dbname}.stb1 partition by tbname")
|
||||||
tdSql.checkRows(20)
|
tdSql.checkRows(20)
|
||||||
|
|
||||||
tdSql.query("select count(c1) from stb1 where t1> 4 partition by tbname")
|
tdSql.query(f"select count(c1) from {dbname}.stb1 where t1> 4 partition by tbname")
|
||||||
tdSql.checkRows(15)
|
tdSql.checkRows(15)
|
||||||
|
|
||||||
# union all
|
# union all
|
||||||
tdSql.query("select count(c1) from stb1 union all select count(c1) from stb1 ")
|
tdSql.query(f"select count(c1) from {dbname}.stb1 union all select count(c1) from {dbname}.stb1 ")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0,0,184)
|
tdSql.checkData(0,0,184)
|
||||||
|
|
||||||
|
@ -221,60 +193,60 @@ class TDTestCase:
|
||||||
|
|
||||||
tdSql.execute(" create database if not exists db ")
|
tdSql.execute(" create database if not exists db ")
|
||||||
tdSql.execute(" use db ")
|
tdSql.execute(" use db ")
|
||||||
tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ")
|
tdSql.execute(" create stable db.st (ts timestamp , c1 int ,c2 float) tags(t1 int) ")
|
||||||
tdSql.execute(" create table tb1 using st tags(1) ")
|
tdSql.execute(" create table db.tb1 using db.st tags(1) ")
|
||||||
tdSql.execute(" create table tb2 using st tags(2) ")
|
tdSql.execute(" create table db.tb2 using db.st tags(2) ")
|
||||||
|
|
||||||
|
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
ts = i*10 + self.ts
|
ts = i*10 + self.ts
|
||||||
tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)")
|
tdSql.execute(f" insert into db.tb1 values({ts},{i},{i}.0)")
|
||||||
tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)")
|
tdSql.execute(f" insert into db.tb2 values({ts},{i},{i}.0)")
|
||||||
|
|
||||||
tdSql.query("select count(tb1.c1), count(tb2.c2) from tb1, tb2 where tb1.ts=tb2.ts")
|
tdSql.query(f"select count(tb1.c1), count(tb2.c2) from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,10)
|
tdSql.checkData(0,0,10)
|
||||||
tdSql.checkData(0,1,10)
|
tdSql.checkData(0,1,10)
|
||||||
|
|
||||||
# group by
|
# group by
|
||||||
tdSql.execute(" use testdb ")
|
tdSql.execute(f" use {dbname} ")
|
||||||
|
|
||||||
tdSql.query(" select count(*) from stb1 ")
|
tdSql.query(f"select count(*) from {dbname}.stb1 ")
|
||||||
tdSql.checkData(0,0,187)
|
tdSql.checkData(0,0,187)
|
||||||
tdSql.query(" select count(*) from stb1 group by t1 ")
|
tdSql.query(f"select count(*) from {dbname}.stb1 group by t1 ")
|
||||||
tdSql.checkRows(20)
|
tdSql.checkRows(20)
|
||||||
tdSql.query(" select count(*) from stb1 group by c1 ")
|
tdSql.query(f"select count(*) from {dbname}.stb1 group by c1 ")
|
||||||
tdSql.checkRows(30)
|
tdSql.checkRows(30)
|
||||||
tdSql.query(" select count(*) from stb1 group by c2 ")
|
tdSql.query(f"select count(*) from {dbname}.stb1 group by c2 ")
|
||||||
tdSql.checkRows(31)
|
tdSql.checkRows(31)
|
||||||
|
|
||||||
# partition by tbname or partition by tag
|
# partition by tbname or partition by tag
|
||||||
tdSql.query("select max(c1),tbname from stb1 partition by tbname")
|
tdSql.query(f"select max(c1),tbname from {dbname}.stb1 partition by tbname")
|
||||||
query_data = tdSql.queryResult
|
query_data = tdSql.queryResult
|
||||||
|
|
||||||
for row in query_data:
|
for row in query_data:
|
||||||
tbname = row[1]
|
tbname = f"{dbname}.{row[1]}"
|
||||||
tdSql.query(" select max(c1) from %s "%tbname)
|
tdSql.query(f"select max(c1) from %s "%tbname)
|
||||||
tdSql.checkData(0,0,row[0])
|
tdSql.checkData(0,0,row[0])
|
||||||
|
|
||||||
tdSql.query("select max(c1),tbname from stb1 partition by t1")
|
tdSql.query(f"select max(c1),tbname from {dbname}.stb1 partition by t1")
|
||||||
query_data = tdSql.queryResult
|
query_data = tdSql.queryResult
|
||||||
|
|
||||||
for row in query_data:
|
for row in query_data:
|
||||||
tbname = row[1]
|
tbname = f"{dbname}.{row[1]}"
|
||||||
tdSql.query(" select max(c1) from %s "%tbname)
|
tdSql.query(f"select max(c1) from %s "%tbname)
|
||||||
tdSql.checkData(0,0,row[0])
|
tdSql.checkData(0,0,row[0])
|
||||||
|
|
||||||
# nest query for support max
|
# nest query for support max
|
||||||
tdSql.query("select abs(c2+2)+1 from (select count(c1) c2 from stb1)")
|
tdSql.query(f"select abs(c2+2)+1 from (select count(c1) c2 from {dbname}.stb1)")
|
||||||
tdSql.checkData(0,0,187.000000000)
|
tdSql.checkData(0,0,187.000000000)
|
||||||
tdSql.query("select count(c1+2) as c2 from (select ts ,c1 ,c2 from stb1)")
|
tdSql.query(f"select count(c1+2) as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)")
|
||||||
tdSql.checkData(0,0,184)
|
tdSql.checkData(0,0,184)
|
||||||
tdSql.query("select count(a+2) as c2 from (select ts ,abs(c1) a ,c2 from stb1)")
|
tdSql.query(f"select count(a+2) as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)")
|
||||||
tdSql.checkData(0,0,184)
|
tdSql.checkData(0,0,184)
|
||||||
|
|
||||||
# mixup with other functions
|
# mixup with other functions
|
||||||
tdSql.query("select max(c1),count(c1),last(c2,c3) from stb1")
|
tdSql.query(f"select max(c1),count(c1),last(c2,c3) from {dbname}.stb1")
|
||||||
tdSql.checkData(0,0,28)
|
tdSql.checkData(0,0,28)
|
||||||
tdSql.checkData(0,1,184)
|
tdSql.checkData(0,1,184)
|
||||||
tdSql.checkData(0,2,-99999)
|
tdSql.checkData(0,2,-99999)
|
||||||
|
|
|
@ -6,10 +6,8 @@ import random
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
|
|
||||||
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
|
updatecfgDict = {"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
|
||||||
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143,
|
|
||||||
"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
|
|
||||||
|
|
||||||
def init(self, conn, logSql):
|
def init(self, conn, logSql):
|
||||||
tdLog.debug("start to execute %s" % __file__)
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
|
@ -36,75 +34,52 @@ class TDTestCase:
|
||||||
tdLog.info(" max function work as expected, sql : %s "% max_sql)
|
tdLog.info(" max function work as expected, sql : %s "% max_sql)
|
||||||
|
|
||||||
|
|
||||||
def prepare_datas_of_distribute(self):
|
def prepare_datas_of_distribute(self, dbname="testdb"):
|
||||||
|
|
||||||
# prepate datas for 20 tables distributed at different vgroups
|
# prepate datas for 20 tables distributed at different vgroups
|
||||||
tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5")
|
tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5")
|
||||||
tdSql.execute(" use testdb ")
|
tdSql.execute(f" use {dbname} ")
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
'''create table stb1
|
f'''create table {dbname}.stb1
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||||
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
|
||||||
'''
|
|
||||||
create table t1
|
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
|
||||||
'''
|
|
||||||
)
|
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in range(1,21):
|
for i in range(1,21):
|
||||||
if i ==1 or i == 4:
|
if i ==1 or i == 4:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
tbname = "ct"+f'{i}'
|
tbname = f"{dbname}.ct{i}"
|
||||||
for j in range(9):
|
for j in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )"
|
f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )"
|
||||||
)
|
)
|
||||||
tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
|
|
||||||
tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
|
|
||||||
tdSql.execute(
|
|
||||||
f'''insert into t1 values
|
|
||||||
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
|
||||||
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
|
|
||||||
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
|
||||||
( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a )
|
|
||||||
( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a )
|
|
||||||
( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
|
||||||
( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a )
|
|
||||||
( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a )
|
|
||||||
( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
|
|
||||||
( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
|
|
||||||
( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
|
|
||||||
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
|
||||||
'''
|
|
||||||
)
|
|
||||||
|
|
||||||
tdLog.info(" prepare data for distributed_aggregate done! ")
|
tdLog.info(" prepare data for distributed_aggregate done! ")
|
||||||
|
|
||||||
def check_distribute_datas(self):
|
def check_distribute_datas(self, dbname="testdb"):
|
||||||
# get vgroup_ids of all
|
# get vgroup_ids of all
|
||||||
tdSql.query("show vgroups ")
|
tdSql.query(f"show {dbname}.vgroups ")
|
||||||
vgroups = tdSql.queryResult
|
vgroups = tdSql.queryResult
|
||||||
|
|
||||||
vnode_tables={}
|
vnode_tables={}
|
||||||
|
@ -112,9 +87,8 @@ class TDTestCase:
|
||||||
for vgroup_id in vgroups:
|
for vgroup_id in vgroups:
|
||||||
vnode_tables[vgroup_id[0]]=[]
|
vnode_tables[vgroup_id[0]]=[]
|
||||||
|
|
||||||
|
|
||||||
# check sub_table of per vnode ,make sure sub_table has been distributed
|
# check sub_table of per vnode ,make sure sub_table has been distributed
|
||||||
tdSql.query("show tables like 'ct%'")
|
tdSql.query(f"show {dbname}.tables like 'ct%'")
|
||||||
table_names = tdSql.queryResult
|
table_names = tdSql.queryResult
|
||||||
tablenames = []
|
tablenames = []
|
||||||
for table_name in table_names:
|
for table_name in table_names:
|
||||||
|
@ -128,7 +102,7 @@ class TDTestCase:
|
||||||
if count < 2:
|
if count < 2:
|
||||||
tdLog.exit(" the datas of all not satisfy sub_table has been distributed ")
|
tdLog.exit(" the datas of all not satisfy sub_table has been distributed ")
|
||||||
|
|
||||||
def check_max_distribute_diff_vnode(self,col_name):
|
def check_max_distribute_diff_vnode(self,col_name, dbname="testdb"):
|
||||||
|
|
||||||
vgroup_ids = []
|
vgroup_ids = []
|
||||||
for k ,v in self.vnode_disbutes.items():
|
for k ,v in self.vnode_disbutes.items():
|
||||||
|
@ -146,9 +120,9 @@ class TDTestCase:
|
||||||
|
|
||||||
tbname_filters = tbname_ins[:-1]
|
tbname_filters = tbname_ins[:-1]
|
||||||
|
|
||||||
max_sql = f"select max({col_name}) from stb1 where tbname in ({tbname_filters});"
|
max_sql = f"select max({col_name}) from {dbname}.stb1 where tbname in ({tbname_filters});"
|
||||||
|
|
||||||
same_sql = f"select {col_name} from stb1 where tbname in ({tbname_filters}) order by {col_name} desc limit 1"
|
same_sql = f"select {col_name} from {dbname}.stb1 where tbname in ({tbname_filters}) order by {col_name} desc limit 1"
|
||||||
|
|
||||||
tdSql.query(max_sql)
|
tdSql.query(max_sql)
|
||||||
max_result = tdSql.queryResult
|
max_result = tdSql.queryResult
|
||||||
|
@ -161,16 +135,16 @@ class TDTestCase:
|
||||||
else:
|
else:
|
||||||
tdLog.info(" max function work as expected, sql : %s "% max_sql)
|
tdLog.info(" max function work as expected, sql : %s "% max_sql)
|
||||||
|
|
||||||
def check_max_status(self):
|
def check_max_status(self, dbname="testdb"):
|
||||||
# check max function work status
|
# check max function work status
|
||||||
|
|
||||||
tdSql.query("show tables like 'ct%'")
|
tdSql.query(f"show {dbname}.tables like 'ct%'")
|
||||||
table_names = tdSql.queryResult
|
table_names = tdSql.queryResult
|
||||||
tablenames = []
|
tablenames = []
|
||||||
for table_name in table_names:
|
for table_name in table_names:
|
||||||
tablenames.append(table_name[0])
|
tablenames.append(f"{dbname}.{table_name[0]}")
|
||||||
|
|
||||||
tdSql.query("desc stb1")
|
tdSql.query(f"desc {dbname}.stb1")
|
||||||
col_names = tdSql.queryResult
|
col_names = tdSql.queryResult
|
||||||
|
|
||||||
colnames = []
|
colnames = []
|
||||||
|
@ -186,34 +160,33 @@ class TDTestCase:
|
||||||
|
|
||||||
for colname in colnames:
|
for colname in colnames:
|
||||||
if colname.startswith("c"):
|
if colname.startswith("c"):
|
||||||
self.check_max_distribute_diff_vnode(colname)
|
self.check_max_distribute_diff_vnode(colname, dbname)
|
||||||
else:
|
else:
|
||||||
# self.check_max_distribute_diff_vnode(colname) # bug for tag
|
# self.check_max_distribute_diff_vnode(colname, dbname) # bug for tag
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def distribute_agg_query(self, dbname="testdb"):
|
||||||
def distribute_agg_query(self):
|
|
||||||
# basic filter
|
# basic filter
|
||||||
tdSql.query("select max(c1) from stb1 where c1 is null")
|
tdSql.query(f"select max(c1) from {dbname}.stb1 where c1 is null")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
tdSql.query("select max(c1) from stb1 where t1=1")
|
tdSql.query(f"select max(c1) from {dbname}.stb1 where t1=1")
|
||||||
tdSql.checkData(0,0,10)
|
tdSql.checkData(0,0,10)
|
||||||
|
|
||||||
tdSql.query("select max(c1+c2) from stb1 where c1 =1 ")
|
tdSql.query(f"select max(c1+c2) from {dbname}.stb1 where c1 =1 ")
|
||||||
tdSql.checkData(0,0,11112.000000000)
|
tdSql.checkData(0,0,11112.000000000)
|
||||||
|
|
||||||
tdSql.query("select max(c1) from stb1 where tbname=\"ct2\"")
|
tdSql.query(f"select max(c1) from {dbname}.stb1 where tbname=\"ct2\"")
|
||||||
tdSql.checkData(0,0,10)
|
tdSql.checkData(0,0,10)
|
||||||
|
|
||||||
tdSql.query("select max(c1) from stb1 partition by tbname")
|
tdSql.query(f"select max(c1) from {dbname}.stb1 partition by tbname")
|
||||||
tdSql.checkRows(20)
|
tdSql.checkRows(20)
|
||||||
|
|
||||||
tdSql.query("select max(c1) from stb1 where t1> 4 partition by tbname")
|
tdSql.query(f"select max(c1) from {dbname}.stb1 where t1> 4 partition by tbname")
|
||||||
tdSql.checkRows(15)
|
tdSql.checkRows(15)
|
||||||
|
|
||||||
# union all
|
# union all
|
||||||
tdSql.query("select max(c1) from stb1 union all select max(c1) from stb1 ")
|
tdSql.query(f"select max(c1) from {dbname}.stb1 union all select max(c1) from {dbname}.stb1 ")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0,0,28)
|
tdSql.checkData(0,0,28)
|
||||||
|
|
||||||
|
@ -221,45 +194,45 @@ class TDTestCase:
|
||||||
|
|
||||||
tdSql.execute(" create database if not exists db ")
|
tdSql.execute(" create database if not exists db ")
|
||||||
tdSql.execute(" use db ")
|
tdSql.execute(" use db ")
|
||||||
tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ")
|
tdSql.execute(" create stable db.st (ts timestamp , c1 int ,c2 float) tags(t1 int) ")
|
||||||
tdSql.execute(" create table tb1 using st tags(1) ")
|
tdSql.execute(" create table db.tb1 using db.st tags(1) ")
|
||||||
tdSql.execute(" create table tb2 using st tags(2) ")
|
tdSql.execute(" create table db.tb2 using db.st tags(2) ")
|
||||||
|
|
||||||
|
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
ts = i*10 + self.ts
|
ts = i*10 + self.ts
|
||||||
tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)")
|
tdSql.execute(f" insert into db.tb1 values({ts},{i},{i}.0)")
|
||||||
tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)")
|
tdSql.execute(f" insert into db.tb2 values({ts},{i},{i}.0)")
|
||||||
|
|
||||||
tdSql.query("select max(tb1.c1), tb2.c2 from tb1, tb2 where tb1.ts=tb2.ts")
|
tdSql.query(f"select max(tb1.c1), tb2.c2 from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,9)
|
tdSql.checkData(0,0,9)
|
||||||
tdSql.checkData(0,0,9.00000)
|
tdSql.checkData(0,0,9.00000)
|
||||||
|
|
||||||
# group by
|
# group by
|
||||||
tdSql.execute(" use testdb ")
|
tdSql.execute("use testdb ")
|
||||||
tdSql.query(" select max(c1),c1 from stb1 group by t1 ")
|
tdSql.query(f"select max(c1),c1 from {dbname}.stb1 group by t1 ")
|
||||||
tdSql.checkRows(20)
|
tdSql.checkRows(20)
|
||||||
tdSql.query(" select max(c1),c1 from stb1 group by c1 ")
|
tdSql.query(f"select max(c1),c1 from {dbname}.stb1 group by c1 ")
|
||||||
tdSql.checkRows(30)
|
tdSql.checkRows(30)
|
||||||
tdSql.query(" select max(c1),c2 from stb1 group by c2 ")
|
tdSql.query(f"select max(c1),c2 from {dbname}.stb1 group by c2 ")
|
||||||
tdSql.checkRows(31)
|
tdSql.checkRows(31)
|
||||||
|
|
||||||
# selective common cols of datas
|
# selective common cols of datas
|
||||||
tdSql.query("select max(c1),c2,c3,c5 from stb1")
|
tdSql.query(f"select max(c1),c2,c3,c5 from {dbname}.stb1")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,28)
|
tdSql.checkData(0,0,28)
|
||||||
tdSql.checkData(0,1,311108)
|
tdSql.checkData(0,1,311108)
|
||||||
tdSql.checkData(0,2,3108)
|
tdSql.checkData(0,2,3108)
|
||||||
tdSql.checkData(0,3,31.08000)
|
tdSql.checkData(0,3,31.08000)
|
||||||
|
|
||||||
tdSql.query("select max(c1),t1,c2,t3 from stb1")
|
tdSql.query(f"select max(c1),t1,c2,t3 from {dbname}.stb1")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,28)
|
tdSql.checkData(0,0,28)
|
||||||
tdSql.checkData(0,1,19)
|
tdSql.checkData(0,1,19)
|
||||||
tdSql.checkData(0,2,311108)
|
tdSql.checkData(0,2,311108)
|
||||||
|
|
||||||
tdSql.query("select max(c1),ceil(t1),pow(c2,1)+2,abs(t3) from stb1")
|
tdSql.query(f"select max(c1),ceil(t1),pow(c2,1)+2,abs(t3) from {dbname}.stb1")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,28)
|
tdSql.checkData(0,0,28)
|
||||||
tdSql.checkData(0,1,19)
|
tdSql.checkData(0,1,19)
|
||||||
|
@ -267,32 +240,32 @@ class TDTestCase:
|
||||||
tdSql.checkData(0,3,2109)
|
tdSql.checkData(0,3,2109)
|
||||||
|
|
||||||
# partition by tbname or partition by tag
|
# partition by tbname or partition by tag
|
||||||
tdSql.query("select max(c1),tbname from stb1 partition by tbname")
|
tdSql.query(f"select max(c1),tbname from {dbname}.stb1 partition by tbname")
|
||||||
query_data = tdSql.queryResult
|
query_data = tdSql.queryResult
|
||||||
|
|
||||||
for row in query_data:
|
for row in query_data:
|
||||||
tbname = row[1]
|
tbname = f"{dbname}.{row[1]}"
|
||||||
tdSql.query(" select max(c1) from %s "%tbname)
|
tdSql.query(f"select max(c1) from %s "%tbname)
|
||||||
tdSql.checkData(0,0,row[0])
|
tdSql.checkData(0,0,row[0])
|
||||||
|
|
||||||
tdSql.query("select max(c1),tbname from stb1 partition by t1")
|
tdSql.query(f"select max(c1),tbname from {dbname}.stb1 partition by t1")
|
||||||
query_data = tdSql.queryResult
|
query_data = tdSql.queryResult
|
||||||
|
|
||||||
for row in query_data:
|
for row in query_data:
|
||||||
tbname = row[1]
|
tbname = f"{dbname}.{row[1]}"
|
||||||
tdSql.query(" select max(c1) from %s "%tbname)
|
tdSql.query(f"select max(c1) from %s "%tbname)
|
||||||
tdSql.checkData(0,0,row[0])
|
tdSql.checkData(0,0,row[0])
|
||||||
|
|
||||||
# nest query for support max
|
# nest query for support max
|
||||||
tdSql.query("select abs(c2+2)+1 from (select max(c1) c2 from stb1)")
|
tdSql.query(f"select abs(c2+2)+1 from (select max(c1) c2 from {dbname}.stb1)")
|
||||||
tdSql.checkData(0,0,31.000000000)
|
tdSql.checkData(0,0,31.000000000)
|
||||||
tdSql.query("select max(c1+2)+1 as c2 from (select ts ,c1 ,c2 from stb1)")
|
tdSql.query(f"select max(c1+2)+1 as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)")
|
||||||
tdSql.checkData(0,0,31.000000000)
|
tdSql.checkData(0,0,31.000000000)
|
||||||
tdSql.query("select max(a+2)+1 as c2 from (select ts ,abs(c1) a ,c2 from stb1)")
|
tdSql.query(f"select max(a+2)+1 as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)")
|
||||||
tdSql.checkData(0,0,31.000000000)
|
tdSql.checkData(0,0,31.000000000)
|
||||||
|
|
||||||
# mixup with other functions
|
# mixup with other functions
|
||||||
tdSql.query("select max(c1),count(c1),last(c2,c3) from stb1")
|
tdSql.query(f"select max(c1),count(c1),last(c2,c3) from {dbname}.stb1")
|
||||||
tdSql.checkData(0,0,28)
|
tdSql.checkData(0,0,28)
|
||||||
tdSql.checkData(0,1,184)
|
tdSql.checkData(0,1,184)
|
||||||
tdSql.checkData(0,2,-99999)
|
tdSql.checkData(0,2,-99999)
|
||||||
|
|
|
@ -6,10 +6,8 @@ import random
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 ,
|
|
||||||
"jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143,
|
updatecfgDict = {"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
|
||||||
"wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143,
|
|
||||||
"maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 }
|
|
||||||
|
|
||||||
def init(self, conn, logSql):
|
def init(self, conn, logSql):
|
||||||
tdLog.debug("start to execute %s" % __file__)
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
|
@ -35,76 +33,52 @@ class TDTestCase:
|
||||||
else:
|
else:
|
||||||
tdLog.info(" min function work as expected, sql : %s "% min_sql)
|
tdLog.info(" min function work as expected, sql : %s "% min_sql)
|
||||||
|
|
||||||
|
def prepare_datas_of_distribute(self, dbname="testdb"):
|
||||||
def prepare_datas_of_distribute(self):
|
|
||||||
|
|
||||||
# prepate datas for 20 tables distributed at different vgroups
|
# prepate datas for 20 tables distributed at different vgroups
|
||||||
tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5")
|
tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5")
|
||||||
tdSql.execute(" use testdb ")
|
tdSql.execute(f" use {dbname} ")
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
'''create table stb1
|
f'''create table {dbname}.stb1
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
||||||
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
tdSql.execute(
|
|
||||||
'''
|
|
||||||
create table t1
|
|
||||||
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
|
|
||||||
'''
|
|
||||||
)
|
|
||||||
for i in range(20):
|
for i in range(20):
|
||||||
tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )')
|
||||||
|
|
||||||
for i in range(9):
|
for i in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||||
)
|
)
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
f"insert into {dbname}.ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )"
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in range(1,21):
|
for i in range(1,21):
|
||||||
if i ==1 or i == 4:
|
if i ==1 or i == 4:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
tbname = "ct"+f'{i}'
|
tbname = f"{dbname}.ct{i}"
|
||||||
for j in range(9):
|
for j in range(9):
|
||||||
tdSql.execute(
|
tdSql.execute(
|
||||||
f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )"
|
f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )"
|
||||||
)
|
)
|
||||||
tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
tdSql.execute(f"insert into {dbname}.ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )")
|
||||||
|
|
||||||
tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
tdSql.execute(f"insert into {dbname}.ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ")
|
||||||
|
|
||||||
tdSql.execute(
|
|
||||||
f'''insert into t1 values
|
|
||||||
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
|
||||||
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
|
|
||||||
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
|
|
||||||
( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a )
|
|
||||||
( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a )
|
|
||||||
( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
|
||||||
( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a )
|
|
||||||
( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a )
|
|
||||||
( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
|
|
||||||
( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
|
|
||||||
( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
|
|
||||||
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
|
||||||
'''
|
|
||||||
)
|
|
||||||
|
|
||||||
tdLog.info(" prepare data for distributed_aggregate done! ")
|
tdLog.info(" prepare data for distributed_aggregate done! ")
|
||||||
|
|
||||||
def check_distribute_datas(self):
|
def check_distribute_datas(self, dbname="testdb"):
|
||||||
# get vgroup_ids of all
|
# get vgroup_ids of all
|
||||||
tdSql.query("show vgroups ")
|
tdSql.query(f"show {dbname}.vgroups ")
|
||||||
vgroups = tdSql.queryResult
|
vgroups = tdSql.queryResult
|
||||||
|
|
||||||
vnode_tables={}
|
vnode_tables={}
|
||||||
|
@ -112,9 +86,8 @@ class TDTestCase:
|
||||||
for vgroup_id in vgroups:
|
for vgroup_id in vgroups:
|
||||||
vnode_tables[vgroup_id[0]]=[]
|
vnode_tables[vgroup_id[0]]=[]
|
||||||
|
|
||||||
|
|
||||||
# check sub_table of per vnode ,make sure sub_table has been distributed
|
# check sub_table of per vnode ,make sure sub_table has been distributed
|
||||||
tdSql.query("show tables like 'ct%'")
|
tdSql.query(f"show {dbname}.tables like 'ct%'")
|
||||||
table_names = tdSql.queryResult
|
table_names = tdSql.queryResult
|
||||||
tablenames = []
|
tablenames = []
|
||||||
for table_name in table_names:
|
for table_name in table_names:
|
||||||
|
@ -128,7 +101,7 @@ class TDTestCase:
|
||||||
if count < 2:
|
if count < 2:
|
||||||
tdLog.exit(" the datas of all not satisfy sub_table has been distributed ")
|
tdLog.exit(" the datas of all not satisfy sub_table has been distributed ")
|
||||||
|
|
||||||
def check_min_distribute_diff_vnode(self,col_name):
|
def check_min_distribute_diff_vnode(self,col_name, dbname="testdb"):
|
||||||
|
|
||||||
vgroup_ids = []
|
vgroup_ids = []
|
||||||
for k ,v in self.vnode_disbutes.items():
|
for k ,v in self.vnode_disbutes.items():
|
||||||
|
@ -146,9 +119,9 @@ class TDTestCase:
|
||||||
|
|
||||||
tbname_filters = tbname_ins[:-1]
|
tbname_filters = tbname_ins[:-1]
|
||||||
|
|
||||||
min_sql = f"select min({col_name}) from stb1 where tbname in ({tbname_filters});"
|
min_sql = f"select min({col_name}) from {dbname}.stb1 where tbname in ({tbname_filters});"
|
||||||
|
|
||||||
same_sql = f"select {col_name} from stb1 where tbname in ({tbname_filters}) and {col_name} is not null order by {col_name} asc limit 1"
|
same_sql = f"select {col_name} from {dbname}.stb1 where tbname in ({tbname_filters}) and {col_name} is not null order by {col_name} asc limit 1"
|
||||||
|
|
||||||
tdSql.query(min_sql)
|
tdSql.query(min_sql)
|
||||||
min_result = tdSql.queryResult
|
min_result = tdSql.queryResult
|
||||||
|
@ -161,16 +134,16 @@ class TDTestCase:
|
||||||
else:
|
else:
|
||||||
tdLog.info(" min function work as expected, sql : %s "% min_sql)
|
tdLog.info(" min function work as expected, sql : %s "% min_sql)
|
||||||
|
|
||||||
def check_min_status(self):
|
def check_min_status(self, dbname="testdb"):
|
||||||
# check max function work status
|
# check min function work status
|
||||||
|
|
||||||
tdSql.query("show tables like 'ct%'")
|
tdSql.query(f"show {dbname}.tables like 'ct%'")
|
||||||
table_names = tdSql.queryResult
|
table_names = tdSql.queryResult
|
||||||
tablenames = []
|
tablenames = []
|
||||||
for table_name in table_names:
|
for table_name in table_names:
|
||||||
tablenames.append(table_name[0])
|
tablenames.append(f"{dbname}.{table_name[0]}")
|
||||||
|
|
||||||
tdSql.query("desc stb1")
|
tdSql.query(f"desc {dbname}.stb1")
|
||||||
col_names = tdSql.queryResult
|
col_names = tdSql.queryResult
|
||||||
|
|
||||||
colnames = []
|
colnames = []
|
||||||
|
@ -182,119 +155,117 @@ class TDTestCase:
|
||||||
for colname in colnames:
|
for colname in colnames:
|
||||||
self.check_min_functions(tablename,colname)
|
self.check_min_functions(tablename,colname)
|
||||||
|
|
||||||
# check max function for different vnode
|
# check min function for different vnode
|
||||||
|
|
||||||
for colname in colnames:
|
for colname in colnames:
|
||||||
if colname.startswith("c"):
|
if colname.startswith("c"):
|
||||||
self.check_min_distribute_diff_vnode(colname)
|
self.check_min_distribute_diff_vnode(colname, dbname)
|
||||||
else:
|
else:
|
||||||
# self.check_min_distribute_diff_vnode(colname) # bug for tag
|
# self.check_min_distribute_diff_vnode(colname, dbname) # bug for tag
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def distribute_agg_query(self, dbname="testdb"):
|
||||||
def distribute_agg_query(self):
|
|
||||||
# basic filter
|
# basic filter
|
||||||
tdSql.query("select min(c1) from stb1 where c1 is null")
|
tdSql.query(f"select min(c1) from {dbname}.stb1 where c1 is null")
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
tdSql.query("select min(c1) from stb1 where t1=1")
|
tdSql.query(f"select min(c1) from {dbname}.stb1 where t1=1")
|
||||||
tdSql.checkData(0,0,2)
|
tdSql.checkData(0,0,2)
|
||||||
|
|
||||||
tdSql.query("select min(c1+c2) from stb1 where c1 =1 ")
|
tdSql.query(f"select min(c1+c2) from {dbname}.stb1 where c1 =1 ")
|
||||||
tdSql.checkData(0,0,11112.000000000)
|
tdSql.checkData(0,0,11112.000000000)
|
||||||
|
|
||||||
tdSql.query("select min(c1) from stb1 where tbname=\"ct2\"")
|
tdSql.query(f"select min(c1) from {dbname}.stb1 where tbname=\"ct2\"")
|
||||||
tdSql.checkData(0,0,2)
|
tdSql.checkData(0, 0, 2)
|
||||||
|
|
||||||
tdSql.query("select min(c1) from stb1 partition by tbname")
|
tdSql.query(f"select min(c1) from {dbname}.stb1 partition by tbname")
|
||||||
tdSql.checkRows(20)
|
tdSql.checkRows(20)
|
||||||
|
|
||||||
tdSql.query("select min(c1) from stb1 where t1> 4 partition by tbname")
|
tdSql.query(f"select min(c1) from {dbname}.stb1 where t1> 4 partition by tbname")
|
||||||
tdSql.checkRows(15)
|
tdSql.checkRows(15)
|
||||||
|
|
||||||
# union all
|
# union all
|
||||||
tdSql.query("select min(c1) from stb1 union all select min(c1) from stb1 ")
|
tdSql.query(f"select min(c1) from {dbname}.stb1 union all select min(c1) from {dbname}.stb1 ")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0, 0, 0)
|
||||||
|
|
||||||
# join
|
# join
|
||||||
|
|
||||||
tdSql.execute(" create database if not exists db ")
|
tdSql.execute(" create database if not exists db ")
|
||||||
tdSql.execute(" use db ")
|
tdSql.execute(" use db ")
|
||||||
tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ")
|
tdSql.execute(" create stable db.st (ts timestamp , c1 int ,c2 float) tags(t1 int) ")
|
||||||
tdSql.execute(" create table tb1 using st tags(1) ")
|
tdSql.execute(" create table db.tb1 using db.st tags(1) ")
|
||||||
tdSql.execute(" create table tb2 using st tags(2) ")
|
tdSql.execute(" create table db.tb2 using db.st tags(2) ")
|
||||||
|
|
||||||
|
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
ts = i*10 + self.ts
|
ts = i*10 + self.ts
|
||||||
tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)")
|
tdSql.execute(f" insert into db.tb1 values({ts},{i},{i}.0)")
|
||||||
tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)")
|
tdSql.execute(f" insert into db.tb2 values({ts},{i},{i}.0)")
|
||||||
|
|
||||||
tdSql.query("select min(tb1.c1), tb2.c2 from tb1, tb2 where tb1.ts=tb2.ts")
|
tdSql.query(f"select min(tb1.c1), tb2.c2 from db.tb1 tb1, db.tb2 tb2 where tb1.ts=tb2.ts")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
tdSql.checkData(0,0,0.00000)
|
tdSql.checkData(0,0,0.00000)
|
||||||
|
|
||||||
# group by
|
# group by
|
||||||
tdSql.execute(" use testdb ")
|
tdSql.execute(f"use {dbname} ")
|
||||||
tdSql.query(" select min(c1),c1 from stb1 group by t1 ")
|
tdSql.query(f"select min(c1),c1 from {dbname}.stb1 group by t1 ")
|
||||||
tdSql.checkRows(20)
|
tdSql.checkRows(20)
|
||||||
tdSql.query(" select min(c1),c1 from stb1 group by c1 ")
|
tdSql.query(f"select min(c1),c1 from {dbname}.stb1 group by c1 ")
|
||||||
tdSql.checkRows(30)
|
tdSql.checkRows(30)
|
||||||
tdSql.query(" select min(c1),c2 from stb1 group by c2 ")
|
tdSql.query(f"select min(c1),c2 from {dbname}.stb1 group by c2 ")
|
||||||
tdSql.checkRows(31)
|
tdSql.checkRows(31)
|
||||||
|
|
||||||
# selective common cols of datas
|
# selective common cols of datas
|
||||||
tdSql.query("select min(c1),c2,c3,c5 from stb1")
|
tdSql.query(f"select min(c1),c2,c3,c5 from {dbname}.stb1")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,0)
|
tdSql.checkData(0,0,0)
|
||||||
tdSql.checkData(0,1,0)
|
tdSql.checkData(0,1,0)
|
||||||
tdSql.checkData(0,2,0)
|
tdSql.checkData(0,2,0)
|
||||||
tdSql.checkData(0,3,0)
|
tdSql.checkData(0,3,0)
|
||||||
|
|
||||||
tdSql.query("select min(c1),t1,c2,t3 from stb1 where c1 >5")
|
tdSql.query(f"select min(c1),t1,c2,t3 from {dbname}.stb1 where c1 > 5")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,6)
|
tdSql.checkData(0,0,6)
|
||||||
tdSql.checkData(0,2,66666)
|
tdSql.checkData(0,2,66666)
|
||||||
|
|
||||||
tdSql.query("select min(c1),ceil(t1),pow(c2,1)+2,abs(t3) from stb1 where c1>12")
|
tdSql.query(f"select min(c1),ceil(t1),pow(c2,1)+2,abs(t3) from {dbname}.stb1 where c1 > 12")
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.checkData(0,0,13)
|
tdSql.checkData(0,0,13)
|
||||||
tdSql.checkData(0,2,144445.000000000)
|
tdSql.checkData(0,2,144445.000000000)
|
||||||
|
|
||||||
# partition by tbname or partition by tag
|
# partition by tbname or partition by tag
|
||||||
tdSql.query("select min(c1),tbname from stb1 partition by tbname")
|
tdSql.query(f"select min(c1),tbname from {dbname}.stb1 partition by tbname")
|
||||||
query_data = tdSql.queryResult
|
query_data = tdSql.queryResult
|
||||||
|
|
||||||
for row in query_data:
|
for row in query_data:
|
||||||
tbname = row[1]
|
tbname = f"{dbname}.{row[1]}"
|
||||||
tdSql.query(" select min(c1) from %s "%tbname)
|
tdSql.query(f"select min(c1) from %s "%tbname)
|
||||||
tdSql.checkData(0,0,row[0])
|
tdSql.checkData(0,0,row[0])
|
||||||
|
|
||||||
tdSql.query("select min(c1),tbname from stb1 partition by t1")
|
tdSql.query(f"select min(c1),tbname from {dbname}.stb1 partition by t1")
|
||||||
query_data = tdSql.queryResult
|
query_data = tdSql.queryResult
|
||||||
|
|
||||||
for row in query_data:
|
for row in query_data:
|
||||||
tbname = row[1]
|
tbname = f"{dbname}.{row[1]}"
|
||||||
tdSql.query(" select min(c1) from %s "%tbname)
|
tdSql.query(f"select min(c1) from %s "%tbname)
|
||||||
tdSql.checkData(0,0,row[0])
|
tdSql.checkData(0,0,row[0])
|
||||||
|
|
||||||
# nest query for support max
|
# nest query for support min
|
||||||
tdSql.query("select abs(c2+2)+1 from (select min(c1) c2 from stb1)")
|
tdSql.query(f"select abs(c2+2)+1 from (select min(c1) c2 from {dbname}.stb1)")
|
||||||
tdSql.checkData(0,0,3.000000000)
|
tdSql.checkData(0,0,3.000000000)
|
||||||
tdSql.query("select min(c1+2)+1 as c2 from (select ts ,c1 ,c2 from stb1)")
|
tdSql.query(f"select min(c1+2)+1 as c2 from (select ts ,c1 ,c2 from {dbname}.stb1)")
|
||||||
tdSql.checkData(0,0,3.000000000)
|
tdSql.checkData(0,0,3.000000000)
|
||||||
tdSql.query("select min(a+2)+1 as c2 from (select ts ,abs(c1) a ,c2 from stb1)")
|
tdSql.query(f"select min(a+2)+1 as c2 from (select ts ,abs(c1) a ,c2 from {dbname}.stb1)")
|
||||||
tdSql.checkData(0,0,3.000000000)
|
tdSql.checkData(0,0,3.000000000)
|
||||||
|
|
||||||
# mixup with other functions
|
# mixup with other functions
|
||||||
tdSql.query("select max(c1),count(c1),last(c2,c3),min(c1) from stb1")
|
tdSql.query(f"select max(c1),count(c1),last(c2,c3) from {dbname}.stb1")
|
||||||
tdSql.checkData(0,0,28)
|
tdSql.checkData(0,0,28)
|
||||||
tdSql.checkData(0,1,184)
|
tdSql.checkData(0,1,184)
|
||||||
tdSql.checkData(0,2,-99999)
|
tdSql.checkData(0,2,-99999)
|
||||||
tdSql.checkData(0,3,-999)
|
tdSql.checkData(0,3,-999)
|
||||||
tdSql.checkData(0,4,0)
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
|
|
|
@ -51,32 +51,32 @@ class TDTestCase:
|
||||||
tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix'])
|
tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix'])
|
||||||
# tdLog.info("insert data")
|
# tdLog.info("insert data")
|
||||||
# tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"])
|
# tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"])
|
||||||
|
|
||||||
tdLog.info("create 4 topics")
|
tdLog.info("create 4 topics")
|
||||||
sqlString = "create topic %s as database %s" %(topicNameList[0], paraDict['dbName'])
|
sqlString = "create topic %s as database %s" %(topicNameList[0], paraDict['dbName'])
|
||||||
tdLog.info("create topic sql: %s"%sqlString)
|
tdLog.info("create topic sql: %s"%sqlString)
|
||||||
tdSql.execute(sqlString)
|
tdSql.execute(sqlString)
|
||||||
|
|
||||||
sqlString = "create topic %s as stable %s.%s" %(topicNameList[1], paraDict['dbName'], paraDict['stbName'])
|
sqlString = "create topic %s as stable %s.%s" %(topicNameList[1], paraDict['dbName'], paraDict['stbName'])
|
||||||
tdLog.info("create topic sql: %s"%sqlString)
|
tdLog.info("create topic sql: %s"%sqlString)
|
||||||
tdSql.execute(sqlString)
|
tdSql.execute(sqlString)
|
||||||
|
|
||||||
queryString = "select * from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName'])
|
queryString = "select * from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName'])
|
||||||
sqlString = "create topic %s as %s" %(topicNameList[2], queryString)
|
sqlString = "create topic %s as %s" %(topicNameList[2], queryString)
|
||||||
tdLog.info("create topic sql: %s"%sqlString)
|
tdLog.info("create topic sql: %s"%sqlString)
|
||||||
tdSql.execute(sqlString)
|
tdSql.execute(sqlString)
|
||||||
|
|
||||||
queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName'])
|
queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName'])
|
||||||
sqlString = "create topic %s as %s " %(topicNameList[3], queryString)
|
sqlString = "create topic %s as %s " %(topicNameList[3], queryString)
|
||||||
tdLog.info("create topic sql: %s"%sqlString)
|
tdLog.info("create topic sql: %s"%sqlString)
|
||||||
tdSql.execute(sqlString)
|
tdSql.execute(sqlString)
|
||||||
|
|
||||||
tdSql.query("show topics")
|
tdSql.query("show topics")
|
||||||
tdLog.debug(tdSql.queryResult)
|
tdLog.debug(tdSql.queryResult)
|
||||||
rows = tdSql.getRows()
|
rows = tdSql.getRows()
|
||||||
if rows != len(consumerIdList):
|
if rows != len(consumerIdList):
|
||||||
tdLog.exit("topic rows error")
|
tdLog.exit("topic rows error")
|
||||||
|
|
||||||
for i in range (rows):
|
for i in range (rows):
|
||||||
topicName = tdSql.getData(i,0)
|
topicName = tdSql.getData(i,0)
|
||||||
matchFlag = 0
|
matchFlag = 0
|
||||||
|
@ -87,24 +87,24 @@ class TDTestCase:
|
||||||
break
|
break
|
||||||
if matchFlag == 0:
|
if matchFlag == 0:
|
||||||
tdLog.exit("topic name: %s is error", topicName)
|
tdLog.exit("topic name: %s is error", topicName)
|
||||||
|
|
||||||
# init consume info, and start tmq_sim, then check consume result
|
# init consume info, and start tmq_sim, then check consume result
|
||||||
tdLog.info("insert consume info to consume processor")
|
tdLog.info("insert consume info to consume processor")
|
||||||
expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"]
|
expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"]
|
||||||
topicList = topicNameList[0]
|
topicList = topicNameList[0]
|
||||||
ifcheckdata = 0
|
ifcheckdata = 0
|
||||||
ifManualCommit = 0
|
ifManualCommit = 0
|
||||||
keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[0]
|
keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[0]
|
||||||
tmqCom.insertConsumerInfo(consumerIdList[0], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
tmqCom.insertConsumerInfo(consumerIdList[0], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
||||||
|
|
||||||
topicList = topicNameList[1]
|
topicList = topicNameList[1]
|
||||||
keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[1]
|
keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[1]
|
||||||
tmqCom.insertConsumerInfo(consumerIdList[1], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
tmqCom.insertConsumerInfo(consumerIdList[1], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
||||||
|
|
||||||
topicList = topicNameList[2]
|
topicList = topicNameList[2]
|
||||||
keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[2]
|
keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[2]
|
||||||
tmqCom.insertConsumerInfo(consumerIdList[2], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
tmqCom.insertConsumerInfo(consumerIdList[2], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
||||||
|
|
||||||
topicList = topicNameList[3]
|
topicList = topicNameList[3]
|
||||||
keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[3]
|
keyList = 'group.id:%s, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'%consumeGroupIdList[3]
|
||||||
tmqCom.insertConsumerInfo(consumerIdList[3], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
tmqCom.insertConsumerInfo(consumerIdList[3], expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
||||||
|
@ -118,27 +118,27 @@ class TDTestCase:
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
tdLog.info("check show consumers")
|
tdLog.info("check show consumers")
|
||||||
tdSql.query("show consumers")
|
tdSql.query("show consumers")
|
||||||
# tdLog.info(tdSql.queryResult)
|
# tdLog.info(tdSql.queryResult)
|
||||||
rows = tdSql.getRows()
|
rows = tdSql.getRows()
|
||||||
tdLog.info("show consumers rows: %d"%rows)
|
tdLog.info("show consumers rows: %d"%rows)
|
||||||
if rows != len(topicNameList):
|
if rows != len(topicNameList):
|
||||||
tdLog.exit("show consumers rows error")
|
tdLog.exit("show consumers rows error")
|
||||||
|
|
||||||
tdLog.info("check show subscriptions")
|
tdLog.info("check show subscriptions")
|
||||||
tdSql.query("show subscriptions")
|
tdSql.query("show subscriptions")
|
||||||
# tdLog.debug(tdSql.queryResult)
|
# tdLog.debug(tdSql.queryResult)
|
||||||
rows = tdSql.getRows()
|
rows = tdSql.getRows()
|
||||||
tdLog.info("show subscriptions rows: %d"%rows)
|
tdLog.info("show subscriptions rows: %d"%rows)
|
||||||
if rows != paraDict['vgroups'] * len(topicNameList):
|
if rows != paraDict['vgroups'] * len(topicNameList):
|
||||||
tdLog.exit("show subscriptions rows error")
|
tdLog.exit("show subscriptions rows error")
|
||||||
|
|
||||||
pThread.join()
|
pThread.join()
|
||||||
|
|
||||||
tdLog.info("insert process end, and start to check consume result")
|
tdLog.info("insert process end, and start to check consume result")
|
||||||
expectRows = len(consumerIdList)
|
expectRows = len(consumerIdList)
|
||||||
_ = tmqCom.selectConsumeResult(expectRows)
|
_ = tmqCom.selectConsumeResult(expectRows)
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
for i in range(len(topicNameList)):
|
for i in range(len(topicNameList)):
|
||||||
tdSql.query("drop topic %s"%topicNameList[i])
|
tdSql.query("drop topic %s"%topicNameList[i])
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
|
||||||
|
import taos
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import socket
|
||||||
|
import os
|
||||||
|
import threading
|
||||||
|
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.dnodes import *
|
||||||
|
from util.common import *
|
||||||
|
sys.path.append("./7-tmq")
|
||||||
|
from tmqCommon import *
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
def init(self, conn, logSql):
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
#tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
||||||
|
|
||||||
|
def checkFileContent(self):
|
||||||
|
buildPath = tdCom.getBuildPath()
|
||||||
|
cfgPath = tdCom.getClientCfgPath()
|
||||||
|
cmdStr = '%s/build/bin/tmq_taosx_ci -c %s'%(buildPath, cfgPath)
|
||||||
|
tdLog.info(cmdStr)
|
||||||
|
os.system(cmdStr)
|
||||||
|
|
||||||
|
srcFile = '%s/../log/tmq_taosx_tmp.source'%(cfgPath)
|
||||||
|
dstFile = '%s/../log/tmq_taosx_tmp.result'%(cfgPath)
|
||||||
|
tdLog.info("compare file: %s, %s"%(srcFile, dstFile))
|
||||||
|
|
||||||
|
consumeFile = open(srcFile, mode='r')
|
||||||
|
queryFile = open(dstFile, mode='r')
|
||||||
|
|
||||||
|
while True:
|
||||||
|
dst = queryFile.readline()
|
||||||
|
src = consumeFile.readline()
|
||||||
|
|
||||||
|
if dst:
|
||||||
|
if dst != src:
|
||||||
|
tdLog.exit("compare error: %s != %s"%src, dst)
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
|
tdSql.execute('use db_taosx')
|
||||||
|
tdSql.query("select * from ct3")
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
tdSql.checkData(0, 1, 51)
|
||||||
|
tdSql.checkData(0, 4, 940)
|
||||||
|
tdSql.checkData(1, 1, 23)
|
||||||
|
tdSql.checkData(1, 4, None)
|
||||||
|
|
||||||
|
tdSql.query("select * from ct1")
|
||||||
|
tdSql.checkRows(4)
|
||||||
|
|
||||||
|
tdSql.query("select * from ct2")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
tdSql.query("select * from ct0")
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
tdSql.checkData(0, 3, "a")
|
||||||
|
tdSql.checkData(1, 4, None)
|
||||||
|
|
||||||
|
tdSql.query("select * from n1")
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
tdSql.checkData(0, 1, "eeee")
|
||||||
|
tdSql.checkData(1, 2, 940)
|
||||||
|
|
||||||
|
tdSql.query("select * from jt")
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
tdSql.checkData(0, 1, 11)
|
||||||
|
tdSql.checkData(0, 2, None)
|
||||||
|
tdSql.checkData(1, 1, 1)
|
||||||
|
tdSql.checkData(1, 2, '{"k1":1,"k2":"hello"}')
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
tdSql.prepare()
|
||||||
|
self.checkFileContent()
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
event = threading.Event()
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -27,7 +27,7 @@ python3 ./test.py -f 1-insert/alter_stable.py
|
||||||
python3 ./test.py -f 1-insert/alter_table.py
|
python3 ./test.py -f 1-insert/alter_table.py
|
||||||
python3 ./test.py -f 1-insert/insertWithMoreVgroup.py
|
python3 ./test.py -f 1-insert/insertWithMoreVgroup.py
|
||||||
python3 ./test.py -f 1-insert/table_comment.py
|
python3 ./test.py -f 1-insert/table_comment.py
|
||||||
#python3 ./test.py -f 1-insert/time_range_wise.py
|
python3 ./test.py -f 1-insert/time_range_wise.py
|
||||||
python3 ./test.py -f 1-insert/block_wise.py
|
python3 ./test.py -f 1-insert/block_wise.py
|
||||||
python3 ./test.py -f 1-insert/create_retentions.py
|
python3 ./test.py -f 1-insert/create_retentions.py
|
||||||
python3 ./test.py -f 1-insert/table_param_ttl.py
|
python3 ./test.py -f 1-insert/table_param_ttl.py
|
||||||
|
@ -59,17 +59,44 @@ python3 ./test.py -f 2-query/ceil.py
|
||||||
python3 ./test.py -f 2-query/ceil.py -R
|
python3 ./test.py -f 2-query/ceil.py -R
|
||||||
python3 ./test.py -f 2-query/char_length.py
|
python3 ./test.py -f 2-query/char_length.py
|
||||||
python3 ./test.py -f 2-query/char_length.py -R
|
python3 ./test.py -f 2-query/char_length.py -R
|
||||||
#python3 ./test.py -f 2-query/check_tsdb.py
|
# python3 ./test.py -f 2-query/check_tsdb.py
|
||||||
#python3 ./test.py -f 2-query/check_tsdb.py -R
|
# python3 ./test.py -f 2-query/check_tsdb.py -R
|
||||||
|
python3 ./test.py -f 2-query/concat.py
|
||||||
|
python3 ./test.py -f 2-query/concat.py -R
|
||||||
|
python3 ./test.py -f 2-query/concat_ws.py
|
||||||
|
python3 ./test.py -f 2-query/concat_ws.py -R
|
||||||
|
python3 ./test.py -f 2-query/concat_ws2.py
|
||||||
|
python3 ./test.py -f 2-query/concat_ws2.py -R
|
||||||
|
python3 ./test.py -f 2-query/cos.py
|
||||||
|
python3 ./test.py -f 2-query/cos.py -R
|
||||||
|
python3 ./test.py -f 2-query/count_partition.py
|
||||||
|
python3 ./test.py -f 2-query/count_partition.py -R
|
||||||
|
python3 ./test.py -f 2-query/count.py
|
||||||
|
python3 ./test.py -f 2-query/count.py -R
|
||||||
|
python3 ./test.py -f 2-query/db.py
|
||||||
|
python3 ./test.py -f 2-query/db.py -R
|
||||||
|
python3 ./test.py -f 2-query/diff.py
|
||||||
|
python3 ./test.py -f 2-query/diff.py -R
|
||||||
|
python3 ./test.py -f 2-query/distinct.py
|
||||||
|
python3 ./test.py -f 2-query/distinct.py -R
|
||||||
|
python3 ./test.py -f 2-query/distribute_agg_apercentile.py
|
||||||
|
python3 ./test.py -f 2-query/distribute_agg_apercentile.py -R
|
||||||
|
python3 ./test.py -f 2-query/distribute_agg_avg.py
|
||||||
|
python3 ./test.py -f 2-query/distribute_agg_avg.py -R
|
||||||
|
python3 ./test.py -f 2-query/distribute_agg_count.py
|
||||||
|
python3 ./test.py -f 2-query/distribute_agg_count.py -R
|
||||||
|
python3 ./test.py -f 2-query/distribute_agg_max.py
|
||||||
|
python3 ./test.py -f 2-query/distribute_agg_max.py -R
|
||||||
|
python3 ./test.py -f 2-query/distribute_agg_min.py
|
||||||
|
python3 ./test.py -f 2-query/distribute_agg_min.py -R
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
python3 ./test.py -f 1-insert/update_data.py
|
python3 ./test.py -f 1-insert/update_data.py
|
||||||
|
|
||||||
python3 ./test.py -f 1-insert/delete_data.py
|
python3 ./test.py -f 1-insert/delete_data.py
|
||||||
python3 ./test.py -f 2-query/db.py
|
|
||||||
|
|
||||||
|
|
||||||
python3 ./test.py -f 2-query/db.py
|
|
||||||
python3 ./test.py -f 2-query/distinct.py
|
|
||||||
python3 ./test.py -f 2-query/varchar.py
|
python3 ./test.py -f 2-query/varchar.py
|
||||||
python3 ./test.py -f 2-query/ltrim.py
|
python3 ./test.py -f 2-query/ltrim.py
|
||||||
python3 ./test.py -f 2-query/rtrim.py
|
python3 ./test.py -f 2-query/rtrim.py
|
||||||
|
@ -81,10 +108,7 @@ python3 ./test.py -f 2-query/join2.py
|
||||||
python3 ./test.py -f 2-query/substr.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/concat2.py
|
python3 ./test.py -f 2-query/concat2.py
|
||||||
python3 ./test.py -f 2-query/concat_ws.py
|
|
||||||
python3 ./test.py -f 2-query/concat_ws2.py
|
|
||||||
python3 ./test.py -f 2-query/spread.py
|
python3 ./test.py -f 2-query/spread.py
|
||||||
python3 ./test.py -f 2-query/hyperloglog.py
|
python3 ./test.py -f 2-query/hyperloglog.py
|
||||||
python3 ./test.py -f 2-query/explain.py
|
python3 ./test.py -f 2-query/explain.py
|
||||||
|
@ -97,13 +121,11 @@ python3 ./test.py -f 2-query/Now.py
|
||||||
python3 ./test.py -f 2-query/Today.py
|
python3 ./test.py -f 2-query/Today.py
|
||||||
python3 ./test.py -f 2-query/max.py
|
python3 ./test.py -f 2-query/max.py
|
||||||
python3 ./test.py -f 2-query/min.py
|
python3 ./test.py -f 2-query/min.py
|
||||||
python3 ./test.py -f 2-query/count.py
|
|
||||||
python3 ./test.py -f 2-query/last.py
|
python3 ./test.py -f 2-query/last.py
|
||||||
python3 ./test.py -f 2-query/first.py
|
python3 ./test.py -f 2-query/first.py
|
||||||
python3 ./test.py -f 2-query/To_iso8601.py
|
python3 ./test.py -f 2-query/To_iso8601.py
|
||||||
python3 ./test.py -f 2-query/To_unixtimestamp.py
|
python3 ./test.py -f 2-query/To_unixtimestamp.py
|
||||||
python3 ./test.py -f 2-query/timetruncate.py
|
python3 ./test.py -f 2-query/timetruncate.py
|
||||||
python3 ./test.py -f 2-query/diff.py
|
|
||||||
python3 ./test.py -f 2-query/Timediff.py
|
python3 ./test.py -f 2-query/Timediff.py
|
||||||
python3 ./test.py -f 2-query/json_tag.py
|
python3 ./test.py -f 2-query/json_tag.py
|
||||||
|
|
||||||
|
@ -115,7 +137,6 @@ python3 ./test.py -f 2-query/log.py
|
||||||
python3 ./test.py -f 2-query/pow.py
|
python3 ./test.py -f 2-query/pow.py
|
||||||
python3 ./test.py -f 2-query/sqrt.py
|
python3 ./test.py -f 2-query/sqrt.py
|
||||||
python3 ./test.py -f 2-query/sin.py
|
python3 ./test.py -f 2-query/sin.py
|
||||||
python3 ./test.py -f 2-query/cos.py
|
|
||||||
python3 ./test.py -f 2-query/tan.py
|
python3 ./test.py -f 2-query/tan.py
|
||||||
python3 ./test.py -f 2-query/query_cols_tags_and_or.py
|
python3 ./test.py -f 2-query/query_cols_tags_and_or.py
|
||||||
# python3 ./test.py -f 2-query/nestedQuery.py
|
# python3 ./test.py -f 2-query/nestedQuery.py
|
||||||
|
@ -126,7 +147,6 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py
|
||||||
python3 ./test.py -f 2-query/elapsed.py
|
python3 ./test.py -f 2-query/elapsed.py
|
||||||
python3 ./test.py -f 2-query/csum.py
|
python3 ./test.py -f 2-query/csum.py
|
||||||
python3 ./test.py -f 2-query/mavg.py
|
python3 ./test.py -f 2-query/mavg.py
|
||||||
python3 ./test.py -f 2-query/diff.py
|
|
||||||
python3 ./test.py -f 2-query/sample.py
|
python3 ./test.py -f 2-query/sample.py
|
||||||
python3 ./test.py -f 2-query/function_diff.py
|
python3 ./test.py -f 2-query/function_diff.py
|
||||||
python3 ./test.py -f 2-query/unique.py
|
python3 ./test.py -f 2-query/unique.py
|
||||||
|
@ -135,17 +155,11 @@ python3 ./test.py -f 2-query/function_stateduration.py
|
||||||
python3 ./test.py -f 2-query/statecount.py
|
python3 ./test.py -f 2-query/statecount.py
|
||||||
python3 ./test.py -f 2-query/tail.py
|
python3 ./test.py -f 2-query/tail.py
|
||||||
python3 ./test.py -f 2-query/ttl_comment.py
|
python3 ./test.py -f 2-query/ttl_comment.py
|
||||||
python3 ./test.py -f 2-query/distribute_agg_count.py
|
|
||||||
python3 ./test.py -f 2-query/distribute_agg_max.py
|
|
||||||
python3 ./test.py -f 2-query/distribute_agg_min.py
|
|
||||||
python3 ./test.py -f 2-query/distribute_agg_sum.py
|
python3 ./test.py -f 2-query/distribute_agg_sum.py
|
||||||
python3 ./test.py -f 2-query/distribute_agg_spread.py
|
python3 ./test.py -f 2-query/distribute_agg_spread.py
|
||||||
python3 ./test.py -f 2-query/distribute_agg_apercentile.py
|
|
||||||
python3 ./test.py -f 2-query/distribute_agg_avg.py
|
|
||||||
python3 ./test.py -f 2-query/distribute_agg_stddev.py
|
python3 ./test.py -f 2-query/distribute_agg_stddev.py
|
||||||
python3 ./test.py -f 2-query/twa.py
|
python3 ./test.py -f 2-query/twa.py
|
||||||
python3 ./test.py -f 2-query/irate.py
|
python3 ./test.py -f 2-query/irate.py
|
||||||
python3 ./test.py -f 2-query/count_partition.py
|
|
||||||
python3 ./test.py -f 2-query/function_null.py
|
python3 ./test.py -f 2-query/function_null.py
|
||||||
python3 ./test.py -f 2-query/queryQnode.py
|
python3 ./test.py -f 2-query/queryQnode.py
|
||||||
python3 ./test.py -f 2-query/max_partition.py
|
python3 ./test.py -f 2-query/max_partition.py
|
||||||
|
@ -168,12 +182,12 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeRestartDnodeInsertData.py -N 5 -M 3
|
||||||
# python3 ./test.py -f 6-cluster/5dnode3mnodeRestartMnodeInsertData.py -N 5 -M 3
|
# python3 ./test.py -f 6-cluster/5dnode3mnodeRestartMnodeInsertData.py -N 5 -M 3
|
||||||
# python3 ./test.py -f 6-cluster/5dnode3mnodeRestartVnodeInsertData.py -N 5 -M 3
|
# python3 ./test.py -f 6-cluster/5dnode3mnodeRestartVnodeInsertData.py -N 5 -M 3
|
||||||
|
|
||||||
python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5
|
python3 ./test.py -f 6-cluster/5dnode3mnodeAdd1Ddnoe.py -N 6 -M 3 -C 5
|
||||||
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py
|
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py
|
||||||
# python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py -N 5
|
# python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py -N 5
|
||||||
# python3 test.py -f 6-cluster/5dnode3mnodeStopConnect.py -N 5 -M 3
|
# python3 test.py -f 6-cluster/5dnode3mnodeStopConnect.py -N 5 -M 3
|
||||||
|
|
||||||
python3 ./test.py -f 7-tmq/dropDbR3ConflictTransaction.py -N 3
|
python3 ./test.py -f 7-tmq/dropDbR3ConflictTransaction.py -N 3
|
||||||
python3 ./test.py -f 7-tmq/basic5.py
|
python3 ./test.py -f 7-tmq/basic5.py
|
||||||
python3 ./test.py -f 7-tmq/subscribeDb.py
|
python3 ./test.py -f 7-tmq/subscribeDb.py
|
||||||
python3 ./test.py -f 7-tmq/subscribeDb0.py
|
python3 ./test.py -f 7-tmq/subscribeDb0.py
|
||||||
|
@ -227,6 +241,7 @@ python3 ./test.py -f 7-tmq/tmqUdf-multCtb-snapshot1.py
|
||||||
python3 ./test.py -f 7-tmq/stbTagFilter-1ctb.py
|
python3 ./test.py -f 7-tmq/stbTagFilter-1ctb.py
|
||||||
python3 ./test.py -f 7-tmq/dataFromTsdbNWal.py
|
python3 ./test.py -f 7-tmq/dataFromTsdbNWal.py
|
||||||
python3 ./test.py -f 7-tmq/dataFromTsdbNWal-multiCtb.py
|
python3 ./test.py -f 7-tmq/dataFromTsdbNWal-multiCtb.py
|
||||||
|
python3 ./test.py -f 7-tmq/tmq_taosx.py
|
||||||
# python3 ./test.py -f 7-tmq/stbTagFilter-multiCtb.py
|
# python3 ./test.py -f 7-tmq/stbTagFilter-multiCtb.py
|
||||||
|
|
||||||
#------------querPolicy 2-----------
|
#------------querPolicy 2-----------
|
||||||
|
@ -295,7 +310,6 @@ python3 ./test.py -f 2-query/avg.py -Q 2
|
||||||
# python3 ./test.py -f 2-query/elapsed.py -Q 2
|
# python3 ./test.py -f 2-query/elapsed.py -Q 2
|
||||||
python3 ./test.py -f 2-query/csum.py -Q 2
|
python3 ./test.py -f 2-query/csum.py -Q 2
|
||||||
python3 ./test.py -f 2-query/mavg.py -Q 2
|
python3 ./test.py -f 2-query/mavg.py -Q 2
|
||||||
python3 ./test.py -f 2-query/diff.py -Q 2
|
|
||||||
python3 ./test.py -f 2-query/sample.py -Q 2
|
python3 ./test.py -f 2-query/sample.py -Q 2
|
||||||
python3 ./test.py -f 2-query/function_diff.py -Q 2
|
python3 ./test.py -f 2-query/function_diff.py -Q 2
|
||||||
python3 ./test.py -f 2-query/unique.py -Q 2
|
python3 ./test.py -f 2-query/unique.py -Q 2
|
||||||
|
@ -383,7 +397,6 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 3
|
||||||
# python3 ./test.py -f 2-query/elapsed.py -Q 3
|
# python3 ./test.py -f 2-query/elapsed.py -Q 3
|
||||||
python3 ./test.py -f 2-query/csum.py -Q 3
|
python3 ./test.py -f 2-query/csum.py -Q 3
|
||||||
python3 ./test.py -f 2-query/mavg.py -Q 3
|
python3 ./test.py -f 2-query/mavg.py -Q 3
|
||||||
python3 ./test.py -f 2-query/diff.py -Q 3
|
|
||||||
python3 ./test.py -f 2-query/sample.py -Q 3
|
python3 ./test.py -f 2-query/sample.py -Q 3
|
||||||
python3 ./test.py -f 2-query/function_diff.py -Q 3
|
python3 ./test.py -f 2-query/function_diff.py -Q 3
|
||||||
python3 ./test.py -f 2-query/unique.py -Q 3
|
python3 ./test.py -f 2-query/unique.py -Q 3
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
add_executable(tmq_demo tmqDemo.c)
|
add_executable(tmq_demo tmqDemo.c)
|
||||||
add_executable(tmq_sim tmqSim.c)
|
add_executable(tmq_sim tmqSim.c)
|
||||||
add_executable(create_table createTable.c)
|
add_executable(create_table createTable.c)
|
||||||
|
add_executable(tmq_taosx_ci tmq_taosx_ci.c)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
create_table
|
create_table
|
||||||
PUBLIC taos_static
|
PUBLIC taos_static
|
||||||
|
@ -22,6 +23,13 @@ target_link_libraries(
|
||||||
PUBLIC common
|
PUBLIC common
|
||||||
PUBLIC os
|
PUBLIC os
|
||||||
)
|
)
|
||||||
|
target_link_libraries(
|
||||||
|
tmq_taosx_ci
|
||||||
|
PUBLIC taos_static
|
||||||
|
PUBLIC util
|
||||||
|
PUBLIC common
|
||||||
|
PUBLIC os
|
||||||
|
)
|
||||||
|
|
||||||
add_executable(sdbDump sdbDump.c)
|
add_executable(sdbDump sdbDump.c)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
|
|
|
@ -0,0 +1,520 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include "taos.h"
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
static int running = 1;
|
||||||
|
TdFilePtr g_fp = NULL;
|
||||||
|
char dir[64]={0};
|
||||||
|
|
||||||
|
static TAOS* use_db(){
|
||||||
|
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
if (pConn == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(pConn, "use db_taosx");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("error in use db_taosx, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
return pConn;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void msg_process(TAOS_RES* msg) {
|
||||||
|
/*memset(buf, 0, 1024);*/
|
||||||
|
printf("-----------topic-------------: %s\n", tmq_get_topic_name(msg));
|
||||||
|
printf("db: %s\n", tmq_get_db_name(msg));
|
||||||
|
printf("vg: %d\n", tmq_get_vgroup_id(msg));
|
||||||
|
TAOS *pConn = use_db();
|
||||||
|
if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META) {
|
||||||
|
char* result = tmq_get_json_meta(msg);
|
||||||
|
if (result) {
|
||||||
|
printf("meta result: %s\n", result);
|
||||||
|
}
|
||||||
|
taosFprintfFile(g_fp, result);
|
||||||
|
taosFprintfFile(g_fp, "\n");
|
||||||
|
tmq_free_json_meta(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
tmq_raw_data raw = {0};
|
||||||
|
tmq_get_raw(msg, &raw);
|
||||||
|
int32_t ret = tmq_write_raw(pConn, raw);
|
||||||
|
printf("write raw data: %s\n", tmq_err2str(ret));
|
||||||
|
|
||||||
|
// else{
|
||||||
|
// while(1){
|
||||||
|
// int numOfRows = 0;
|
||||||
|
// void *pData = NULL;
|
||||||
|
// taos_fetch_raw_block(msg, &numOfRows, &pData);
|
||||||
|
// if(numOfRows == 0) break;
|
||||||
|
// printf("write data: tbname:%s, numOfRows:%d\n", tmq_get_table_name(msg), numOfRows);
|
||||||
|
// int ret = taos_write_raw_block(pConn, numOfRows, pData, tmq_get_table_name(msg));
|
||||||
|
// printf("write raw data: %s\n", tmq_err2str(ret));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
taos_close(pConn);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t init_env() {
|
||||||
|
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
if (pConn == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(pConn, "drop database if exists db_taosx");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("error in drop db_taosx, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create database if not exists db_taosx vgroups 1");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("error in create db_taosx, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "drop database if exists abc1");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("error in drop db, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "use abc1");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn,
|
||||||
|
"create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 "
|
||||||
|
"nchar(8), t4 bool)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create table if not exists ct0 using st1 tags(1000, \"ttt\", true)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create child table tu1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "insert into ct0 values(1626006833600, 1, 2, 'a')");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to insert into ct0, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create table if not exists ct1 using st1(t1) tags(2000)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create child table ct1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create table if not exists ct2 using st1(t1) tags(NULL)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create child table ct2, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "insert into ct1 values(1626006833600, 3, 4, 'b')");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to insert into ct1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create table if not exists ct3 using st1(t1) tags(3000)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create child table ct3, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "insert into ct3 values(1626006833600, 5, 6, 'c') ct1 values(1626006833601, 2, 3, 'sds') (1626006833602, 4, 5, 'ddd') ct0 values(1626006833602, 4, 3, 'hwj') ct1 values(now+5s, 23, 32, 's21ds')");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "alter table st1 add column c4 bigint");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "alter table st1 modify column c3 binary(64)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "insert into ct3 values(1626006833605, 53, 63, 'cffffffffffffffffffffffffffff', 8989898899999) (1626006833609, 51, 62, 'c333', 940)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "insert into ct3 select * from ct1");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "alter table st1 add tag t2 binary(64)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "alter table ct3 set tag t1=5000");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to slter child table ct3, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "delete from abc1 .ct3 where ts < 1626006833606");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create table if not exists n1(ts timestamp, c1 int, c2 nchar(4))");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "alter table n1 add column c3 bigint");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "alter table n1 modify column c2 nchar(8)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "alter table n1 rename column c3 cc3");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "alter table n1 comment 'hello'");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "alter table n1 drop column c1");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "insert into n1 values(now, 'eeee', 8989898899999) (now+9s, 'c333', 940)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to insert into n1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create table jt(ts timestamp, i int) tags(t json)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create super table jt, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create table jt1 using jt tags('{\"k1\":1, \"k2\":\"hello\"}')");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create super table jt, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create table jt2 using jt tags('')");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create super table jt2, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "insert into jt1 values(now, 1)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create super table jt1, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "insert into jt2 values(now, 11)");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create super table jt2, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
taos_close(pConn);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t create_topic() {
|
||||||
|
printf("create topic\n");
|
||||||
|
TAOS_RES* pRes;
|
||||||
|
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
if (pConn == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "use abc1");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
pRes = taos_query(pConn, "create topic topic_ctb_column with meta as database abc1");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("failed to create topic topic_ctb_column, reason:%s\n", taos_errstr(pRes));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
|
||||||
|
taos_close(pConn);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) {
|
||||||
|
printf("commit %d tmq %p param %p\n", code, tmq, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
tmq_t* build_consumer() {
|
||||||
|
#if 0
|
||||||
|
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
assert(pConn != NULL);
|
||||||
|
|
||||||
|
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||||
|
if (taos_errno(pRes) != 0) {
|
||||||
|
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
||||||
|
}
|
||||||
|
taos_free_result(pRes);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
tmq_conf_t* conf = tmq_conf_new();
|
||||||
|
tmq_conf_set(conf, "group.id", "tg2");
|
||||||
|
tmq_conf_set(conf, "client.id", "my app 1");
|
||||||
|
tmq_conf_set(conf, "td.connect.user", "root");
|
||||||
|
tmq_conf_set(conf, "td.connect.pass", "taosdata");
|
||||||
|
tmq_conf_set(conf, "msg.with.table.name", "true");
|
||||||
|
tmq_conf_set(conf, "enable.auto.commit", "true");
|
||||||
|
tmq_conf_set(conf, "enable.heartbeat.background", "true");
|
||||||
|
|
||||||
|
/*tmq_conf_set(conf, "experimental.snapshot.enable", "true");*/
|
||||||
|
|
||||||
|
tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL);
|
||||||
|
tmq_t* tmq = tmq_consumer_new(conf, NULL, 0);
|
||||||
|
assert(tmq);
|
||||||
|
tmq_conf_destroy(conf);
|
||||||
|
return tmq;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmq_list_t* build_topic_list() {
|
||||||
|
tmq_list_t* topic_list = tmq_list_new();
|
||||||
|
tmq_list_append(topic_list, "topic_ctb_column");
|
||||||
|
/*tmq_list_append(topic_list, "tmq_test_db_multi_insert_topic");*/
|
||||||
|
return topic_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
void basic_consume_loop(tmq_t* tmq, tmq_list_t* topics) {
|
||||||
|
int32_t code;
|
||||||
|
|
||||||
|
if ((code = tmq_subscribe(tmq, topics))) {
|
||||||
|
fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(code));
|
||||||
|
printf("subscribe err\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int32_t cnt = 0;
|
||||||
|
while (running) {
|
||||||
|
TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, 1000);
|
||||||
|
if (tmqmessage) {
|
||||||
|
cnt++;
|
||||||
|
msg_process(tmqmessage);
|
||||||
|
/*if (cnt >= 2) break;*/
|
||||||
|
/*printf("get data\n");*/
|
||||||
|
taos_free_result(tmqmessage);
|
||||||
|
/*} else {*/
|
||||||
|
/*break;*/
|
||||||
|
/*tmq_commit_sync(tmq, NULL);*/
|
||||||
|
}else{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
code = tmq_consumer_close(tmq);
|
||||||
|
if (code)
|
||||||
|
fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(code));
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%% Consumer closed\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void sync_consume_loop(tmq_t* tmq, tmq_list_t* topics) {
|
||||||
|
static const int MIN_COMMIT_COUNT = 1;
|
||||||
|
|
||||||
|
int msg_count = 0;
|
||||||
|
int32_t code;
|
||||||
|
|
||||||
|
if ((code = tmq_subscribe(tmq, topics))) {
|
||||||
|
fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(code));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmq_list_t* subList = NULL;
|
||||||
|
tmq_subscription(tmq, &subList);
|
||||||
|
char** subTopics = tmq_list_to_c_array(subList);
|
||||||
|
int32_t sz = tmq_list_get_size(subList);
|
||||||
|
printf("subscribed topics: ");
|
||||||
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
|
printf("%s, ", subTopics[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
tmq_list_destroy(subList);
|
||||||
|
|
||||||
|
while (running) {
|
||||||
|
TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, 1000);
|
||||||
|
if (tmqmessage) {
|
||||||
|
msg_process(tmqmessage);
|
||||||
|
taos_free_result(tmqmessage);
|
||||||
|
|
||||||
|
/*tmq_commit_sync(tmq, NULL);*/
|
||||||
|
/*if ((++msg_count % MIN_COMMIT_COUNT) == 0) tmq_commit(tmq, NULL, 0);*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
code = tmq_consumer_close(tmq);
|
||||||
|
if (code)
|
||||||
|
fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(code));
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%% Consumer closed\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void initLogFile() {
|
||||||
|
char f1[256] = {0};
|
||||||
|
char f2[256] = {0};
|
||||||
|
|
||||||
|
sprintf(f1, "%s/../log/tmq_taosx_tmp.source", dir);
|
||||||
|
sprintf(f2, "%s/../log/tmq_taosx_tmp.result", dir);
|
||||||
|
TdFilePtr pFile = taosOpenFile(f1, TD_FILE_TEXT | TD_FILE_TRUNC | TD_FILE_STREAM);
|
||||||
|
if (NULL == pFile) {
|
||||||
|
fprintf(stderr, "Failed to open %s for save result\n", f1);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
g_fp = pFile;
|
||||||
|
|
||||||
|
TdFilePtr pFile2 = taosOpenFile(f2, TD_FILE_TEXT | TD_FILE_TRUNC | TD_FILE_STREAM);
|
||||||
|
if (NULL == pFile2) {
|
||||||
|
fprintf(stderr, "Failed to open %s for save result\n", f2);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
char *result[] = {
|
||||||
|
"{\"type\":\"create\",\"tableName\":\"st1\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":6},{\"name\":\"c3\",\"type\":8,\"length\":16}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1}]}",
|
||||||
|
"{\"type\":\"create\",\"tableName\":\"ct0\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":1000},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"ttt\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]}",
|
||||||
|
"{\"type\":\"create\",\"tableName\":\"ct1\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2000}]}",
|
||||||
|
"{\"type\":\"create\",\"tableName\":\"ct2\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[]}",
|
||||||
|
"{\"type\":\"create\",\"tableName\":\"ct3\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":3000}]}",
|
||||||
|
"{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":5,\"colName\":\"c4\",\"colType\":5}",
|
||||||
|
"{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":7,\"colName\":\"c3\",\"colType\":8,\"colLength\":64}",
|
||||||
|
"{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":1,\"colName\":\"t2\",\"colType\":8,\"colLength\":64}",
|
||||||
|
"{\"type\":\"alter\",\"tableName\":\"ct3\",\"tableType\":\"child\",\"alterType\":4,\"colName\":\"t1\",\"colValue\":\"5000\",\"colValueNull\":false}",
|
||||||
|
"{\"type\":\"create\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":10,\"length\":4}],\"tags\":[]}",
|
||||||
|
"{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":5,\"colName\":\"c3\",\"colType\":5}",
|
||||||
|
"{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":7,\"colName\":\"c2\",\"colType\":10,\"colLength\":8}",
|
||||||
|
"{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":10,\"colName\":\"c3\",\"colNewName\":\"cc3\"}",
|
||||||
|
"{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":9}",
|
||||||
|
"{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":6,\"colName\":\"c1\"}",
|
||||||
|
"{\"type\":\"create\",\"tableName\":\"jt\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"i\",\"type\":4}],\"tags\":[{\"name\":\"t\",\"type\":15}]}",
|
||||||
|
"{\"type\":\"create\",\"tableName\":\"jt1\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[{\"name\":\"t\",\"type\":15,\"value\":\"{\\\"k1\\\":1,\\\"k2\\\":\\\"hello\\\"}\"}]}",
|
||||||
|
"{\"type\":\"create\",\"tableName\":\"jt2\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[]}"
|
||||||
|
};
|
||||||
|
|
||||||
|
for(int i = 0; i < sizeof(result)/sizeof(result[0]); i++){
|
||||||
|
taosFprintfFile(pFile2, result[i]);
|
||||||
|
taosFprintfFile(pFile2, "\n");
|
||||||
|
}
|
||||||
|
taosCloseFile(&pFile2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
if(argc == 3 && strcmp(argv[1], "-c") == 0) {
|
||||||
|
strcpy(dir, argv[2]);
|
||||||
|
}else{
|
||||||
|
strcpy(dir, "../../../sim/psim/cfg");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("env init\n");
|
||||||
|
initLogFile();
|
||||||
|
|
||||||
|
if (init_env() < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
create_topic();
|
||||||
|
|
||||||
|
tmq_t* tmq = build_consumer();
|
||||||
|
tmq_list_t* topic_list = build_topic_list();
|
||||||
|
basic_consume_loop(tmq, topic_list);
|
||||||
|
/*sync_consume_loop(tmq, topic_list);*/
|
||||||
|
taosCloseFile(&g_fp);
|
||||||
|
}
|
Loading…
Reference in New Issue