Merge branch '3.0' into feature/stream
This commit is contained in:
commit
27c94ac40d
|
@ -0,0 +1 @@
|
|||
*.py linguist-detectable=false
|
|
@ -1,5 +1,6 @@
|
|||
build/
|
||||
compile_commands.json
|
||||
CMakeSettings.json
|
||||
.cache
|
||||
.ycm_extra_conf.py
|
||||
.tasks
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "WSL-GCC-Debug",
|
||||
"generator": "Unix Makefiles",
|
||||
"configurationType": "Debug",
|
||||
"buildRoot": "${projectDir}\\build\\",
|
||||
"installRoot": "${projectDir}\\build\\",
|
||||
"cmakeExecutable": "/usr/bin/cmake",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "linux_x64" ],
|
||||
"wslPath": "${defaultWSLPath}",
|
||||
"addressSanitizerRuntimeFlags": "detect_leaks=0",
|
||||
"variables": [
|
||||
{
|
||||
"name": "CMAKE_INSTALL_PREFIX",
|
||||
"value": "/mnt/d/TDengine/TDengine/build",
|
||||
"type": "PATH"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
BIN
TDenginelogo.png
BIN
TDenginelogo.png
Binary file not shown.
Before Width: | Height: | Size: 19 KiB |
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
title: Connect
|
||||
description: "This document explains how to establish connections to TDengine and how to install and use TDengine connectors."
|
||||
sidebar_label: Connect
|
||||
title: Connect to TDengine
|
||||
description: "How to establish connections to TDengine and how to install and use TDengine connectors."
|
||||
---
|
||||
|
||||
import Tabs from "@theme/Tabs";
|
||||
|
|
|
@ -50,7 +50,7 @@ SELECT _wstartts, count(*), avg(voltage) FROM meters PARTITION BY tbname INTERVA
|
|||
## Delete a Stream
|
||||
|
||||
```sql
|
||||
DROP STREAM [IF NOT EXISTS] stream_name
|
||||
DROP STREAM [IF EXISTS] stream_name
|
||||
```
|
||||
|
||||
This statement deletes the stream processing service only. The data generated by the stream is retained.
|
||||
|
|
|
@ -245,3 +245,35 @@ Provides dnode configuration information.
|
|||
| 1 | dnode_id | INT | Dnode ID |
|
||||
| 2 | name | BINARY(32) | Parameter |
|
||||
| 3 | value | BINARY(64) | Value |
|
||||
|
||||
## INS_TOPICS
|
||||
|
||||
| # | **Column** | **Data Type** | **Description** |
|
||||
| --- | :---------: | ------------ | ------------------------------ |
|
||||
| 1 | topic_name | BINARY(192) | Topic name |
|
||||
| 2 | db_name | BINARY(64) | Database for the topic |
|
||||
| 3 | create_time | TIMESTAMP | Creation time |
|
||||
| 4 | sql | BINARY(1024) | SQL statement used to create the topic |
|
||||
|
||||
## INS_SUBSCRIPTIONS
|
||||
|
||||
| # | **Column** | **Data Type** | **Description** |
|
||||
| --- | :------------: | ------------ | ------------------------ |
|
||||
| 1 | topic_name | BINARY(204) | Subscribed topic |
|
||||
| 2 | consumer_group | BINARY(193) | Subscribed consumer group |
|
||||
| 3 | vgroup_id | INT | Vgroup ID for the consumer |
|
||||
| 4 | consumer_id | BIGINT | Consumer ID |
|
||||
|
||||
## INS_STREAMS
|
||||
|
||||
| # | **Column** | **Data Type** | **Description** |
|
||||
| --- | :----------: | ------------ | --------------------------------------- |
|
||||
| 1 | stream_name | BINARY(64) | Stream name |
|
||||
| 2 | create_time | TIMESTAMP | Creation time |
|
||||
| 3 | sql | BINARY(1024) | SQL statement used to create the stream |
|
||||
| 4 | status | BIANRY(20) | Current status |
|
||||
| 5 | source_db | BINARY(64) | Source database |
|
||||
| 6 | target_db | BIANRY(64) | Target database |
|
||||
| 7 | target_table | BINARY(192) | Target table |
|
||||
| 8 | watermark | BIGINT | Watermark (see stream processing documentation) |
|
||||
| 9 | trigger | INT | Method of triggering the result push (see stream processing documentation) |
|
||||
|
|
|
@ -61,15 +61,6 @@ Provides information about SQL queries currently running. Similar to SHOW QUERIE
|
|||
| 12 | sub_status | BINARY(1000) | Subquery status |
|
||||
| 13 | sql | BINARY(1024) | SQL statement |
|
||||
|
||||
## PERF_TOPICS
|
||||
|
||||
| # | **Column** | **Data Type** | **Description** |
|
||||
| --- | :---------: | ------------ | ------------------------------ |
|
||||
| 1 | topic_name | BINARY(192) | Topic name |
|
||||
| 2 | db_name | BINARY(64) | Database for the topic |
|
||||
| 3 | create_time | TIMESTAMP | Creation time |
|
||||
| 4 | sql | BINARY(1024) | SQL statement used to create the topic |
|
||||
|
||||
## PERF_CONSUMERS
|
||||
|
||||
| # | **Column** | **Data Type** | **Description** |
|
||||
|
@ -83,15 +74,6 @@ Provides information about SQL queries currently running. Similar to SHOW QUERIE
|
|||
| 7 | subscribe_time | TIMESTAMP | Time of first subscription |
|
||||
| 8 | rebalance_time | TIMESTAMP | Time of first rebalance triggering |
|
||||
|
||||
## PERF_SUBSCRIPTIONS
|
||||
|
||||
| # | **Column** | **Data Type** | **Description** |
|
||||
| --- | :------------: | ------------ | ------------------------ |
|
||||
| 1 | topic_name | BINARY(204) | Subscribed topic |
|
||||
| 2 | consumer_group | BINARY(193) | Subscribed consumer group |
|
||||
| 3 | vgroup_id | INT | Vgroup ID for the consumer |
|
||||
| 4 | consumer_id | BIGINT | Consumer ID |
|
||||
|
||||
## PERF_TRANS
|
||||
|
||||
| # | **Column** | **Data Type** | **Description** |
|
||||
|
@ -113,17 +95,3 @@ Provides information about SQL queries currently running. Similar to SHOW QUERIE
|
|||
| 2 | create_time | TIMESTAMP | Creation time |
|
||||
| 3 | stable_name | BINARY(192) | Supertable name |
|
||||
| 4 | vgroup_id | INT | Dedicated vgroup name |
|
||||
|
||||
## PERF_STREAMS
|
||||
|
||||
| # | **Column** | **Data Type** | **Description** |
|
||||
| --- | :----------: | ------------ | --------------------------------------- |
|
||||
| 1 | stream_name | BINARY(64) | Stream name |
|
||||
| 2 | create_time | TIMESTAMP | Creation time |
|
||||
| 3 | sql | BINARY(1024) | SQL statement used to create the stream |
|
||||
| 4 | status | BIANRY(20) | Current status |
|
||||
| 5 | source_db | BINARY(64) | Source database |
|
||||
| 6 | target_db | BIANRY(64) | Target database |
|
||||
| 7 | target_table | BINARY(192) | Target table |
|
||||
| 8 | watermark | BIGINT | Watermark (see stream processing documentation) |
|
||||
| 9 | trigger | INT | Method of triggering the result push (see stream processing documentation) |
|
||||
|
|
|
@ -7,7 +7,7 @@ title: TDengine Go Connector
|
|||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
import Preparition from "./_preparition.mdx"
|
||||
import Preparition from "./_preparation.mdx"
|
||||
import GoInsert from "../../07-develop/03-insert-data/_go_sql.mdx"
|
||||
import GoInfluxLine from "../../07-develop/03-insert-data/_go_line.mdx"
|
||||
import GoOpenTSDBTelnet from "../../07-develop/03-insert-data/_go_opts_telnet.mdx"
|
||||
|
|
|
@ -7,7 +7,7 @@ title: TDengine Rust Connector
|
|||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
import Preparition from "./_preparition.mdx"
|
||||
import Preparition from "./_preparation.mdx"
|
||||
import RustInsert from "../../07-develop/03-insert-data/_rust_sql.mdx"
|
||||
import RustBind from "../../07-develop/03-insert-data/_rust_stmt.mdx"
|
||||
import RustQuery from "../../07-develop/04-query-data/_rust.mdx"
|
||||
|
|
|
@ -7,7 +7,7 @@ description: "taospy is the official Python connector for TDengine. taospy provi
|
|||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
|
||||
`taospy is the official Python connector for TDengine. taospy provides a rich API that makes it easy for Python applications to use TDengine. `taospy` wraps both the [native interface](/reference/connector/cpp) and [REST interface](/reference/rest-api) of TDengine, which correspond to the `taos` and `taosrest` modules of the `taospy` package, respectively.
|
||||
`taospy` is the official Python connector for TDengine. taospy provides a rich API that makes it easy for Python applications to use TDengine. `taospy` wraps both the [native interface](/reference/connector/cpp) and [REST interface](/reference/rest-api) of TDengine, which correspond to the `taos` and `taosrest` modules of the `taospy` package, respectively.
|
||||
In addition to wrapping the native and REST interfaces, `taospy` also provides a set of programming interfaces that conforms to the [Python Data Access Specification (PEP 249)](https://peps.python.org/pep-0249/). It is easy to integrate `taospy` with many third-party tools, such as [SQLAlchemy](https://www.sqlalchemy.org/) and [pandas](https://pandas.pydata.org/).
|
||||
|
||||
The direct connection to the server using the native interface provided by the client driver is referred to hereinafter as a "native connection"; the connection to the server using the REST interface provided by taosAdapter is referred to hereinafter as a "REST connection".
|
||||
|
|
|
@ -7,7 +7,7 @@ title: TDengine Node.js Connector
|
|||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
|
||||
import Preparition from "./_preparition.mdx";
|
||||
import Preparition from "./_preparation.mdx";
|
||||
import NodeInsert from "../../07-develop/03-insert-data/_js_sql.mdx";
|
||||
import NodeInfluxLine from "../../07-develop/03-insert-data/_js_line.mdx";
|
||||
import NodeOpenTSDBTelnet from "../../07-develop/03-insert-data/_js_opts_telnet.mdx";
|
||||
|
|
|
@ -7,7 +7,7 @@ title: C# Connector
|
|||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
import Preparition from "./_preparition.mdx"
|
||||
import Preparition from "./_preparation.mdx"
|
||||
import CSInsert from "../../07-develop/03-insert-data/_cs_sql.mdx"
|
||||
import CSInfluxLine from "../../07-develop/03-insert-data/_cs_line.mdx"
|
||||
import CSOpenTSDBTelnet from "../../07-develop/03-insert-data/_cs_opts_telnet.mdx"
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
- 已安装客户端驱动(使用原生连接必须安装,使用 REST 连接无需安装)
|
||||
|
||||
:::info
|
||||
|
||||
由于 TDengine 的客户端驱动使用 C 语言编写,使用原生连接时需要加载系统对应安装在本地的客户端驱动共享库文件,通常包含在 TDengine 安装包。TDengine Linux 服务端安装包附带了 TDengine 客户端,也可以单独安装 [Linux 客户端](/get-started/) 。在 Windows 环境开发时需要安装 TDengine 对应的 [Windows 客户端](https://www.taosdata.com/cn/all-downloads/#TDengine-Windows-Client) 。
|
||||
|
||||
- libtaos.so: 在 Linux 系统中成功安装 TDengine 后,依赖的 Linux 版客户端驱动 libtaos.so 文件会被自动拷贝至 /usr/lib/libtaos.so,该目录包含在 Linux 自动扫描路径上,无需单独指定。
|
||||
- taos.dll: 在 Windows 系统中安装完客户端之后,依赖的 Windows 版客户端驱动 taos.dll 文件会自动拷贝到系统默认搜索路径 C:/Windows/System32 下,同样无需要单独指定。
|
||||
|
||||
:::
|
|
@ -26,7 +26,7 @@ TDengine 的主要功能如下:
|
|||
- [Icinga2](../third-party/icinga2)
|
||||
- [TCollector](../third-party/tcollector)
|
||||
- [EMQX](../third-party/emq-broker)
|
||||
- [HiveMQ](../third-party/hive-mq-broker) ;
|
||||
- [HiveMQ](../third-party/hive-mq-broker)
|
||||
2. 查询数据,支持
|
||||
- [标准 SQL](../taos-sql),含嵌套查询
|
||||
- [时序数据特色函数](../taos-sql/function/#time-series-extensions)
|
||||
|
@ -85,14 +85,14 @@ TDengine 的主要功能如下:
|
|||
|
||||

|
||||
|
||||
<center><figcaption>图 1. TDengine技术生态图</figcaption></center>
|
||||
<center><figcaption>图 1. TDengine 技术生态图</figcaption></center>
|
||||
</figure>
|
||||
|
||||
上图中,左侧是各种数据采集或消息队列,包括 OPC-UA、MQTT、Telegraf、也包括 Kafka,他们的数据将被源源不断的写入到 TDengine。右侧则是可视化、BI 工具、组态软件、应用程序。下侧则是 TDengine 自身提供的命令行程序(CLI)以及可视化管理工具。
|
||||
|
||||
## 典型适用场景
|
||||
|
||||
作为一个高性能、分布式、支持 SQL 的时序数据库(Database),TDengine 的典型适用场景包括但不限于 IoT、工业互联网、车联网、IT 运维、能源、金融证券等领域。需要指出的是,TDengine 是针对时序数据场景设计的专用数据库和专用大数据处理工具,因其充分利用了时序大数据的特点,它无法用来处理网络爬虫、微博、微信、电商、ERP、CRM 等通用型数据。下面本文将对适用场景做更多详细的分析。
|
||||
作为一个高性能、分布式、支持 SQL 的时序数据库(Database),TDengine 的典型适用场景包括但不限于 IoT、工业互联网、车联网、IT 运维、能源、金融证券等领域。需要指出的是,TDengine 是针对时序数据场景设计的专用数据库和专用大数据处理工具,因其充分利用了时序大数据的特点,它无法用来处理网络爬虫、微博、微信、电商、ERP、CRM 等通用型数据。下面本文将对适用场景做更多详细的分析。
|
||||
|
||||
### 数据源特点和需求
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ SELECT _wstartts, count(*), avg(voltage) FROM meters PARTITION BY tbname INTERVA
|
|||
## 删除流式计算
|
||||
|
||||
```sql
|
||||
DROP STREAM [IF NOT EXISTS] stream_name;
|
||||
DROP STREAM [IF EXISTS] stream_name;
|
||||
```
|
||||
|
||||
仅删除流式计算任务,由流式计算写入的数据不会被删除。
|
||||
|
|
|
@ -246,3 +246,35 @@ Note: 由于 SHOW 语句已经被开发者熟悉和广泛使用,所以它们
|
|||
| 1 | dnode_id | INT | dnode 的 ID |
|
||||
| 2 | name | BINARY(32) | 配置项名称 |
|
||||
| 3 | value | BINARY(64) | 该配置项的值 |
|
||||
|
||||
## INS_TOPICS
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :---------: | ------------ | ------------------------------ |
|
||||
| 1 | topic_name | BINARY(192) | topic 名称 |
|
||||
| 2 | db_name | BINARY(64) | topic 相关的 DB |
|
||||
| 3 | create_time | TIMESTAMP | topic 的 创建时间 |
|
||||
| 4 | sql | BINARY(1024) | 创建该 topic 时所用的 SQL 语句 |
|
||||
|
||||
## INS_SUBSCRIPTIONS
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :------------: | ------------ | ------------------------ |
|
||||
| 1 | topic_name | BINARY(204) | 被订阅的 topic |
|
||||
| 2 | consumer_group | BINARY(193) | 订阅者的消费者组 |
|
||||
| 3 | vgroup_id | INT | 消费者被分配的 vgroup id |
|
||||
| 4 | consumer_id | BIGINT | 消费者的唯一 id |
|
||||
|
||||
## INS_STREAMS
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :----------: | ------------ | --------------------------------------- |
|
||||
| 1 | stream_name | BINARY(64) | 流计算名称 |
|
||||
| 2 | create_time | TIMESTAMP | 创建时间 |
|
||||
| 3 | sql | BINARY(1024) | 创建流计算时提供的 SQL 语句 |
|
||||
| 4 | status | BIANRY(20) | 流当前状态 |
|
||||
| 5 | source_db | BINARY(64) | 源数据库 |
|
||||
| 6 | target_db | BIANRY(64) | 目的数据库 |
|
||||
| 7 | target_table | BINARY(192) | 流计算写入的目标表 |
|
||||
| 8 | watermark | BIGINT | watermark,详见 SQL 手册流式计算 |
|
||||
| 9 | trigger | INT | 计算结果推送模式,详见 SQL 手册流式计算 |
|
||||
|
|
|
@ -62,15 +62,6 @@ TDengine 3.0 版本开始提供一个内置数据库 `performance_schema`,其
|
|||
| 12 | sub_status | BINARY(1000) | 子查询状态 |
|
||||
| 13 | sql | BINARY(1024) | SQL 语句 |
|
||||
|
||||
## PERF_TOPICS
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :---------: | ------------ | ------------------------------ |
|
||||
| 1 | topic_name | BINARY(192) | topic 名称 |
|
||||
| 2 | db_name | BINARY(64) | topic 相关的 DB |
|
||||
| 3 | create_time | TIMESTAMP | topic 的 创建时间 |
|
||||
| 4 | sql | BINARY(1024) | 创建该 topic 时所用的 SQL 语句 |
|
||||
|
||||
## PERF_CONSUMERS
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
|
@ -84,15 +75,6 @@ TDengine 3.0 版本开始提供一个内置数据库 `performance_schema`,其
|
|||
| 7 | subscribe_time | TIMESTAMP | 上一次发起订阅的时间 |
|
||||
| 8 | rebalance_time | TIMESTAMP | 上一次触发 rebalance 的时间 |
|
||||
|
||||
## PERF_SUBSCRIPTIONS
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :------------: | ------------ | ------------------------ |
|
||||
| 1 | topic_name | BINARY(204) | 被订阅的 topic |
|
||||
| 2 | consumer_group | BINARY(193) | 订阅者的消费者组 |
|
||||
| 3 | vgroup_id | INT | 消费者被分配的 vgroup id |
|
||||
| 4 | consumer_id | BIGINT | 消费者的唯一 id |
|
||||
|
||||
## PERF_TRANS
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
|
@ -114,17 +96,3 @@ TDengine 3.0 版本开始提供一个内置数据库 `performance_schema`,其
|
|||
| 2 | create_time | TIMESTAMP | sma 创建时间 |
|
||||
| 3 | stable_name | BINARY(192) | sma 所属的超级表名称 |
|
||||
| 4 | vgroup_id | INT | sma 专属的 vgroup 名称 |
|
||||
|
||||
## PERF_STREAMS
|
||||
|
||||
| # | **列名** | **数据类型** | **说明** |
|
||||
| --- | :----------: | ------------ | --------------------------------------- |
|
||||
| 1 | stream_name | BINARY(64) | 流计算名称 |
|
||||
| 2 | create_time | TIMESTAMP | 创建时间 |
|
||||
| 3 | sql | BINARY(1024) | 创建流计算时提供的 SQL 语句 |
|
||||
| 4 | status | BIANRY(20) | 流当前状态 |
|
||||
| 5 | source_db | BINARY(64) | 源数据库 |
|
||||
| 6 | target_db | BIANRY(64) | 目的数据库 |
|
||||
| 7 | target_table | BINARY(192) | 流计算写入的目标表 |
|
||||
| 8 | watermark | BIGINT | watermark,详见 SQL 手册流式计算 |
|
||||
| 9 | trigger | INT | 计算结果推送模式,详见 SQL 手册流式计算 |
|
||||
|
|
|
@ -87,7 +87,7 @@ taosBenchmark -f <json file>
|
|||
<summary>subscribe.json</summary>
|
||||
|
||||
```json
|
||||
{{#include /taos-tools/example/subscribe.json}}
|
||||
{{#include /taos-tools/example/tmq.json}}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
@ -405,37 +405,7 @@ taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\)
|
|||
|
||||
订阅子表或者普通表的配置参数在 `specified_table_query` 中设置。
|
||||
|
||||
- **threads** : 执行 SQL 的线程数,默认为 1。
|
||||
|
||||
- **interval** : 执行订阅的时间间隔,单位为秒,默认为 0。
|
||||
|
||||
- **restart** : "yes" 表示开始新的订阅,"no" 表示继续之前的订阅,默认值为 "no"。
|
||||
|
||||
- **keepProgress** : "yes" 表示保留订阅进度,"no" 表示不保留,默认值为 "no"。
|
||||
|
||||
- **resubAfterConsume** : "yes" 表示取消之前的订阅然后再次订阅, "no" 表示继续之前的订阅,默认值为 "no"。
|
||||
- **threads/concurrent** : 执行 SQL 的线程数,默认为 1。
|
||||
|
||||
- **sqls** :
|
||||
- **sql** : 执行的 SQL 命令,必填。
|
||||
- **result** : 保存查询结果的文件,未指定则不保存。
|
||||
|
||||
#### 订阅超级表的配置参数
|
||||
|
||||
订阅超级表的配置参数在 `super_table_query` 中设置。
|
||||
|
||||
- **stblname** : 要订阅的超级表名称,必填。
|
||||
|
||||
- **threads** : 执行 SQL 的线程数,默认为 1。
|
||||
|
||||
- **interval** : 执行订阅的时间间隔,单位为秒,默认为 0。
|
||||
|
||||
- **restart** : "yes" 表示开始新的订阅,"no" 表示继续之前的订阅,默认值为 "no"。
|
||||
|
||||
- **keepProgress** : "yes" 表示保留订阅进度,"no" 表示不保留,默认值为 "no"。
|
||||
|
||||
- **resubAfterConsume** : "yes" 表示取消之前的订阅然后再次订阅, "no" 表示继续之前的订阅,默认值为 "no"。
|
||||
|
||||
- **sqls** :
|
||||
- **sql** : 执行的 SQL 命令,必填;对于超级表的查询 SQL,在 SQL 命令中保留 "xxxx",程序会自动将其替换为超级表的所有子表名。
|
||||
替换为超级表中所有的子表名。
|
||||
- **result** : 保存查询结果的文件,未指定则不保存。
|
||||
|
|
|
@ -43,17 +43,17 @@ extern "C" {
|
|||
#define TSDB_INS_TABLE_VNODES "ins_vnodes"
|
||||
#define TSDB_INS_TABLE_CONFIGS "ins_configs"
|
||||
#define TSDB_INS_TABLE_DNODE_VARIABLES "ins_dnode_variables"
|
||||
#define TSDB_INS_TABLE_SUBSCRIPTIONS "ins_subscriptions"
|
||||
#define TSDB_INS_TABLE_TOPICS "ins_topics"
|
||||
#define TSDB_INS_TABLE_STREAMS "ins_streams"
|
||||
|
||||
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
|
||||
#define TSDB_PERFS_TABLE_SMAS "perf_smas"
|
||||
#define TSDB_PERFS_TABLE_CONNECTIONS "perf_connections"
|
||||
#define TSDB_PERFS_TABLE_QUERIES "perf_queries"
|
||||
#define TSDB_PERFS_TABLE_TOPICS "perf_topics"
|
||||
#define TSDB_PERFS_TABLE_CONSUMERS "perf_consumers"
|
||||
#define TSDB_PERFS_TABLE_SUBSCRIPTIONS "perf_subscriptions"
|
||||
#define TSDB_PERFS_TABLE_OFFSETS "perf_offsets"
|
||||
#define TSDB_PERFS_TABLE_TRANS "perf_trans"
|
||||
#define TSDB_PERFS_TABLE_STREAMS "perf_streams"
|
||||
#define TSDB_PERFS_TABLE_APPS "perf_apps"
|
||||
|
||||
typedef struct SSysDbTableSchema {
|
||||
|
|
|
@ -2070,6 +2070,7 @@ int32_t tDeserializeSVCreateTbBatchRsp(void* buf, int32_t bufLen, SVCreateTbBatc
|
|||
// TDMT_VND_DROP_TABLE =================
|
||||
typedef struct {
|
||||
char* name;
|
||||
uint64_t suid; // for tmq in wal format
|
||||
int8_t igNotExists;
|
||||
} SVDropTbReq;
|
||||
|
||||
|
|
|
@ -49,9 +49,6 @@ typedef struct {
|
|||
#define varDataCopy(dst, v) memcpy((dst), (void *)(v), varDataTLen(v))
|
||||
#define varDataLenByData(v) (*(VarDataLenT *)(((char *)(v)) - VARSTR_HEADER_SIZE))
|
||||
#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT)(_len))
|
||||
#define IS_VAR_DATA_TYPE(t) \
|
||||
(((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON))
|
||||
#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR))
|
||||
|
||||
#define varDataNetLen(v) (htons(((VarDataLenT *)(v))[0]))
|
||||
#define varDataNetTLen(v) (sizeof(VarDataLenT) + varDataNetLen(v))
|
||||
|
@ -268,11 +265,16 @@ typedef struct {
|
|||
#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT)
|
||||
#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE)
|
||||
#define IS_INTEGER_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)))
|
||||
#define IS_TIMESTAMP_TYPE(_t) ((_t) == TSDB_DATA_TYPE_TIMESTAMP)
|
||||
|
||||
#define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t)))
|
||||
#define IS_MATHABLE_TYPE(_t) \
|
||||
(IS_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP))
|
||||
|
||||
#define IS_VAR_DATA_TYPE(t) \
|
||||
(((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON))
|
||||
#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR))
|
||||
|
||||
#define IS_VALID_TINYINT(_t) ((_t) >= INT8_MIN && (_t) <= INT8_MAX)
|
||||
#define IS_VALID_SMALLINT(_t) ((_t) >= INT16_MIN && (_t) <= INT16_MAX)
|
||||
#define IS_VALID_INT(_t) ((_t) >= INT32_MIN && (_t) <= INT32_MAX)
|
||||
|
|
|
@ -176,7 +176,8 @@ int32_t fmGetFuncInfo(SFunctionNode* pFunc, char* pMsg, int32_t msgLen);
|
|||
|
||||
EFuncReturnRows fmGetFuncReturnRows(SFunctionNode* pFunc);
|
||||
|
||||
bool fmIsBuiltinFunc(const char* pFunc);
|
||||
bool fmIsBuiltinFunc(const char* pFunc);
|
||||
EFunctionType fmGetFuncType(const char* pFunc);
|
||||
|
||||
bool fmIsAggFunc(int32_t funcId);
|
||||
bool fmIsScalarFunc(int32_t funcId);
|
||||
|
|
|
@ -64,6 +64,11 @@ pipeline {
|
|||
defaultValue:'2.1.2',
|
||||
description: 'This number of baseVerison is generally not modified.Now it is 3.0.0.1'
|
||||
)
|
||||
string (
|
||||
name:'nasPassword',
|
||||
defaultValue:'password',
|
||||
description: 'the pasword of the NAS server which has installPackage-192.168.1.131'
|
||||
)
|
||||
}
|
||||
environment{
|
||||
WORK_DIR = '/var/lib/jenkins/workspace'
|
||||
|
@ -111,17 +116,17 @@ pipeline {
|
|||
sync_source("${BRANCH_NAME}")
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server
|
||||
bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server
|
||||
bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_DEB} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server
|
||||
bash testpackage.sh ${TD_SERVER_DEB} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
}
|
||||
|
@ -134,17 +139,22 @@ pipeline {
|
|||
sync_source("${BRANCH_NAME}")
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server
|
||||
bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server
|
||||
bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_DEB} ${version} ${BASE_TD_SERVER_DEB} ${baseVersion} server
|
||||
bash testpackage.sh ${TD_SERVER_DEB} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_CLIENT_TAR} ${version} ${BASE_TD_CLIENT_TAR} ${baseVersion} client ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
}
|
||||
|
@ -157,17 +167,17 @@ pipeline {
|
|||
sync_source("${BRANCH_NAME}")
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server
|
||||
bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server
|
||||
bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_RPM} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server
|
||||
bash testpackage.sh ${TD_SERVER_RPM} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
}
|
||||
|
@ -179,18 +189,42 @@ pipeline {
|
|||
timeout(time: 30, unit: 'MINUTES'){
|
||||
sync_source("${BRANCH_NAME}")
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server
|
||||
bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_RPM} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server
|
||||
bash testpackage.sh ${TD_SERVER_RPM} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_CLIENT_LITE_TAR} ${version} ${BASE_TD_CLIENT_LITE_TAR} ${baseVersion} client ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('arm64') {
|
||||
agent{label 'linux_arm64'}
|
||||
steps {
|
||||
timeout(time: 30, unit: 'MINUTES'){
|
||||
sync_source("${BRANCH_NAME}")
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_ARM_TAR} ${version} ${BASE_TD_SERVER_ARM_TAR} ${baseVersion} server ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_CLIENT_ARM_TAR} ${version} ${BASE_TD_CLIENT_ARM_TAR} ${baseVersion} client ${nasPassword}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/expect
|
||||
set packgeName [lindex $argv 0]
|
||||
set packageSuffix [lindex $argv 1]
|
||||
set timeout 3
|
||||
if { ${packageSuffix} == "deb" } {
|
||||
spawn dpkg -i ${packgeName}
|
||||
} elseif { ${packageSuffix} == "rpm"} {
|
||||
spawn rpm -ivh ${packgeName}
|
||||
}
|
||||
expect "*one:"
|
||||
send "\r"
|
||||
expect "*skip:"
|
||||
send "\r"
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
|
||||
#parameter
|
||||
scriptDir=$(dirname $(readlink -f $0))
|
||||
packgeName=$1
|
||||
version=$2
|
||||
originPackageName=$3
|
||||
|
@ -9,6 +9,17 @@ testFile=$5
|
|||
subFile="taos.tar.gz"
|
||||
password=$6
|
||||
|
||||
# Color setting
|
||||
RED='\033[41;30m'
|
||||
GREEN='\033[1;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[1;34m'
|
||||
GREEN_DARK='\033[0;32m'
|
||||
YELLOW_DARK='\033[0;33m'
|
||||
BLUE_DARK='\033[0;34m'
|
||||
GREEN_UNDERLINE='\033[4;32m'
|
||||
NC='\033[0m'
|
||||
|
||||
if [ ${testFile} = "server" ];then
|
||||
tdPath="TDengine-server-${version}"
|
||||
originTdpPath="TDengine-server-${originversion}"
|
||||
|
@ -24,146 +35,211 @@ elif [ ${testFile} = "tools" ];then
|
|||
fi
|
||||
|
||||
function cmdInstall {
|
||||
comd=$1
|
||||
if command -v ${comd} ;then
|
||||
echo "${comd} is already installed"
|
||||
command=$1
|
||||
if command -v ${command} ;then
|
||||
echoColor YD "${command} is already installed"
|
||||
else
|
||||
if command -v apt ;then
|
||||
apt-get install ${comd} -y
|
||||
apt-get install ${command} -y
|
||||
elif command -v yum ;then
|
||||
yum -y install ${comd}
|
||||
echo "you should install ${comd} manually"
|
||||
yum -y install ${command}
|
||||
echoColor YD "you should install ${command} manually"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function echoColor {
|
||||
color=$1
|
||||
command=$2
|
||||
|
||||
echo "Uninstall all components of TDeingne"
|
||||
|
||||
if command -v rmtaos ;then
|
||||
echo "uninstall all components of TDeingne:rmtaos"
|
||||
rmtaos
|
||||
else
|
||||
echo "os doesn't include TDengine "
|
||||
if [ ${color} = 'Y' ];then
|
||||
echo -e "${YELLOW}${command}${NC}"
|
||||
elif [ ${color} = 'YD' ];then
|
||||
echo -e "${YELLOW_DARK}${command}${NC}"
|
||||
elif [ ${color} = 'R' ];then
|
||||
echo -e "${RED}${command}${NC}"
|
||||
elif [ ${color} = 'G' ];then
|
||||
echo -e "${GREEN}${command}${NC}\r\n"
|
||||
elif [ ${color} = 'B' ];then
|
||||
echo -e "${BLUE}${command}${NC}"
|
||||
elif [ ${color} = 'BD' ];then
|
||||
echo -e "${BLUE_DARK}${command}${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
if command -v rmtaostools ;then
|
||||
echo "uninstall all components of TDeingne:rmtaostools"
|
||||
rmtaostools
|
||||
else
|
||||
echo "os doesn't include rmtaostools "
|
||||
fi
|
||||
|
||||
echoColor G "===== install basesoft ====="
|
||||
|
||||
cmdInstall tree
|
||||
cmdInstall wget
|
||||
cmdInstall sshpass
|
||||
|
||||
echo "new workroom path"
|
||||
echoColor G "===== Uninstall all components of TDeingne ====="
|
||||
|
||||
if command -v rmtaos ;then
|
||||
echoColor YD "uninstall all components of TDeingne:rmtaos"
|
||||
rmtaos
|
||||
else
|
||||
echoColor YD "os doesn't include TDengine"
|
||||
fi
|
||||
|
||||
if command -v rmtaostools ;then
|
||||
echoColor YD "uninstall all components of TDeingne:rmtaostools"
|
||||
rmtaostools
|
||||
else
|
||||
echoColor YD "os doesn't include rmtaostools "
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
echoColor G "===== new workroom path ====="
|
||||
installPath="/usr/local/src/packageTest"
|
||||
oriInstallPath="/usr/local/src/packageTest/3.1"
|
||||
|
||||
if [ ! -d ${installPath} ] ;then
|
||||
echoColor BD "mkdir -p ${installPath}"
|
||||
mkdir -p ${installPath}
|
||||
else
|
||||
echo "${installPath} already exists"
|
||||
echoColor YD "${installPath} already exists"
|
||||
fi
|
||||
|
||||
if [ -d ${installPath}/${tdPath} ] ;then
|
||||
echoColor BD "rm -rf ${installPath}/${tdPath}/*"
|
||||
rm -rf ${installPath}/${tdPath}/*
|
||||
fi
|
||||
|
||||
if [ ! -d ${oriInstallPath} ] ;then
|
||||
echoColor BD "mkdir -p ${oriInstallPath}"
|
||||
mkdir -p ${oriInstallPath}
|
||||
else
|
||||
echo "${oriInstallPath} already exists"
|
||||
echoColor YD "${oriInstallPath} already exists"
|
||||
fi
|
||||
|
||||
if [ -d ${oriInstallPath}/${originTdpPath} ] ;then
|
||||
echoColor BD "rm -rf ${oriInstallPath}/${originTdpPath}/*"
|
||||
rm -rf ${oriInstallPath}/${originTdpPath}/*
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
echo "download installPackage"
|
||||
echoColor G "===== download installPackage ====="
|
||||
# cd ${installPath}
|
||||
# wget https://www.taosdata.com/assets-download/3.0/${packgeName}
|
||||
# cd ${oriInstallPath}
|
||||
# wget https://www.taosdata.com/assets-download/3.0/${originPackageName}
|
||||
|
||||
cd ${installPath}
|
||||
cp -r ${scriptDir}/debRpmAutoInstall.sh .
|
||||
|
||||
if [ ! -f {packgeName} ];then
|
||||
sshpass -p ${password} scp 192.168.1.131:/nas/TDengine3/v${version}/community/${packgeName} .
|
||||
echoColor BD "sshpass -p ${password} scp -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${version}/community/${packgeName} ."
|
||||
sshpass -p ${password} scp -oStrictHostKeyChecking=no -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${version}/community/${packgeName} .
|
||||
fi
|
||||
if [ ! -f debAuto.sh ];then
|
||||
echo '#!/usr/bin/expect ' > debAuto.sh
|
||||
echo 'set timeout 3 ' >> debAuto.sh
|
||||
echo 'pset packgeName [lindex $argv 0]' >> debAuto.sh
|
||||
echo 'spawn dpkg -i ${packgeName}' >> debAuto.sh
|
||||
echo 'expect "*one:"' >> debAuto.sh
|
||||
echo 'send "\r"' >> debAuto.sh
|
||||
echo 'expect "*skip:"' >> debAuto.sh
|
||||
echo 'send "\r" ' >> debAuto.sh
|
||||
|
||||
packageSuffix=$(echo ${packgeName} | awk -F '.' '{print $NF}')
|
||||
|
||||
|
||||
if [ ! -f debRpmAutoInstall.sh ];then
|
||||
echo '#!/usr/bin/expect ' > debRpmAutoInstall.sh
|
||||
echo 'set packgeName [lindex $argv 0]' >> debRpmAutoInstall.sh
|
||||
echo 'set packageSuffix [lindex $argv 1]' >> debRpmAutoInstall.sh
|
||||
echo 'set timeout 3 ' >> debRpmAutoInstall.sh
|
||||
echo 'if { ${packageSuffix} == "deb" } {' >> debRpmAutoInstall.sh
|
||||
echo ' spawn dpkg -i ${packgeName} ' >> debRpmAutoInstall.sh
|
||||
echo '} elseif { ${packageSuffix} == "rpm"} {' >> debRpmAutoInstall.sh
|
||||
echo ' spawn rpm -ivh ${packgeName}' >> debRpmAutoInstall.sh
|
||||
echo '}' >> debRpmAutoInstall.sh
|
||||
echo 'expect "*one:"' >> debRpmAutoInstall.sh
|
||||
echo 'send "\r"' >> debRpmAutoInstall.sh
|
||||
echo 'expect "*skip:"' >> debRpmAutoInstall.sh
|
||||
echo 'send "\r" ' >> debRpmAutoInstall.sh
|
||||
fi
|
||||
|
||||
|
||||
echoColor G "===== instal Package ====="
|
||||
|
||||
if [[ ${packgeName} =~ "deb" ]];then
|
||||
cd ${installPath}
|
||||
dpkg -r taostools
|
||||
dpkg -r tdengine
|
||||
if [[ ${packgeName} =~ "TDengine" ]];then
|
||||
echo "./debAuto.sh ${packgeName}" && chmod 755 debAuto.sh && ./debAuto.sh ${packgeName}
|
||||
echoColor BD "./debRpmAutoInstall.sh ${packgeName} ${packageSuffix}" && chmod 755 debRpmAutoInstall.sh && ./debRpmAutoInstall.sh ${packgeName} ${packageSuffix}
|
||||
else
|
||||
echo "dpkg -i ${packgeName}" && dpkg -i ${packgeName}
|
||||
|
||||
echoColor BD "dpkg -i ${packgeName}" && dpkg -i ${packgeName}
|
||||
fi
|
||||
elif [[ ${packgeName} =~ "rpm" ]];then
|
||||
cd ${installPath}
|
||||
echo "rpm ${packgeName}" && rpm -ivh ${packgeName} --quiet
|
||||
sudo rpm -e tdengine
|
||||
sudo rpm -e taostools
|
||||
if [[ ${packgeName} =~ "TDengine" ]];then
|
||||
echoColor BD "./debRpmAutoInstall.sh ${packgeName} ${packageSuffix}" && chmod 755 debRpmAutoInstall.sh && ./debRpmAutoInstall.sh ${packgeName} ${packageSuffix}
|
||||
else
|
||||
echoColor BD "rpm -ivh ${packgeName}" && rpm -ivh ${packgeName}
|
||||
fi
|
||||
elif [[ ${packgeName} =~ "tar" ]];then
|
||||
echoColor G "===== check installPackage File of tar ====="
|
||||
cd ${oriInstallPath}
|
||||
if [ ! -f {originPackageName} ];then
|
||||
sshpass -p ${password} scp 192.168.1.131:/nas/TDengine3/v${originversion}/community${originPackageName} .
|
||||
echoColor YD "download base installPackage"
|
||||
echoColor BD "sshpass -p ${password} scp -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${originversion}/community/${originPackageName} ."
|
||||
sshpass -p ${password} scp -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${originversion}/community/${originPackageName} .
|
||||
fi
|
||||
echo "tar -xvf ${originPackageName}" && tar -xvf ${originPackageName}
|
||||
|
||||
echoColor YD "unzip the base installation package"
|
||||
echoColor BD "tar -xf ${originPackageName}" && tar -xf ${originPackageName}
|
||||
cd ${installPath}
|
||||
echo "tar -xvf ${packgeName}" && tar -xvf ${packgeName}
|
||||
|
||||
echoColor YD "unzip the new installation package"
|
||||
echoColor BD "tar -xf ${packgeName}" && tar -xf ${packgeName}
|
||||
|
||||
if [ ${testFile} != "tools" ] ;then
|
||||
cd ${installPath}/${tdPath} && tar vxf ${subFile}
|
||||
cd ${oriInstallPath}/${originTdpPath} && tar vxf ${subFile}
|
||||
cd ${installPath}/${tdPath} && tar xf ${subFile}
|
||||
cd ${oriInstallPath}/${originTdpPath} && tar xf ${subFile}
|
||||
fi
|
||||
|
||||
echo "check installPackage File"
|
||||
|
||||
cd ${oriInstallPath}/${originTdpPath} && tree > ${installPath}/base_${originversion}_checkfile
|
||||
cd ${installPath}/${tdPath} && tree > ${installPath}/now_${version}_checkfile
|
||||
|
||||
cd ${installPath}
|
||||
|
||||
tree ${oriInstallPath}/${originTdpPath} > ${oriInstallPath}/${originPackageName}_checkfile
|
||||
tree ${installPath}/${tdPath} > ${installPath}/${packgeName}_checkfile
|
||||
|
||||
diff ${installPath}/${packgeName}_checkfile ${oriInstallPath}/${originPackageName}_checkfile > ${installPath}/diffFile.log
|
||||
diff ${installPath}/base_${originversion}_checkfile ${installPath}/now_${version}_checkfile > ${installPath}/diffFile.log
|
||||
diffNumbers=`cat ${installPath}/diffFile.log |wc -l `
|
||||
if [ ${diffNumbers} != 0 ];then
|
||||
echo "The number and names of files have changed from the previous installation package"
|
||||
echo `cat ${installPath}/diffFile.log`
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if [ ${diffNumbers} != 0 ];then
|
||||
echoColor R "The number and names of files is different from the previous installation package"
|
||||
echoColor Y `cat ${installPath}/diffFile.log`
|
||||
exit -1
|
||||
else
|
||||
echoColor G "The number and names of files are the same as previous installation packages"
|
||||
fi
|
||||
echoColor YD "===== install Package of tar ====="
|
||||
cd ${installPath}/${tdPath}
|
||||
if [ ${testFile} = "server" ];then
|
||||
echoColor BD "bash ${installCmd} -e no "
|
||||
bash ${installCmd} -e no
|
||||
else
|
||||
echoColor BD "bash ${installCmd} "
|
||||
bash ${installCmd}
|
||||
fi
|
||||
if [[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "tar" ]] ;then
|
||||
cd ${installPath}
|
||||
sshpass -p ${password} scp 192.168.1.131:/nas/TDengine3/v${version}/community/taosTools-2.1.2-Linux-x64.tar.gz .
|
||||
# wget https://www.taosdata.com/assets-download/3.0/taosTools-2.1.2-Linux-x64.tar.gz
|
||||
tar xvf taosTools-2.1.2-Linux-x64.tar.gz
|
||||
cd taosTools-2.1.2 && bash install-taostools.sh
|
||||
elif [[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "deb" ]] ;then
|
||||
cd ${installPath}
|
||||
sshpass -p ${password} scp 192.168.1.131:/nas/TDengine3/v${version}/community/taosTools-2.1.2-Linux-x64.deb .
|
||||
dpkg -i taosTools-2.1.2-Linux-x64.deb
|
||||
elif [[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "rpm" ]] ;then
|
||||
cd ${installPath}
|
||||
sshpass -p ${password} scp 192.168.1.131:/nas/TDengine3/v${version}/community/taosTools-2.1.2-Linux-x64.rpm .
|
||||
rpm -ivh taosTools-2.1.2-Linux-x64.rpm --quiet
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
cd ${installPath}
|
||||
|
||||
if ([[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "tar" ]]) || [[ ${packgeName} =~ "client" ]] ;then
|
||||
echoColor G "===== install taos-tools when package is lite or client ====="
|
||||
cd ${installPath}
|
||||
sshpass -p ${password} scp -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${version}/community/taosTools-2.1.2-Linux-x64.tar.gz .
|
||||
# wget https://www.taosdata.com/assets-download/3.0/taosTools-2.1.2-Linux-x64.tar.gz
|
||||
tar xf taosTools-2.1.2-Linux-x64.tar.gz
|
||||
cd taosTools-2.1.2 && bash install-taostools.sh
|
||||
elif [[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "deb" ]] ;then
|
||||
echoColor G "===== install taos-tools when package is lite or client ====="
|
||||
cd ${installPath}
|
||||
sshpass -p ${password} scp -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${version}/community/taosTools-2.1.2-Linux-x64.tar.gz .
|
||||
tar xf taosTools-2.1.2-Linux-x64.tar.gz
|
||||
cd taosTools-2.1.2 && bash install-taostools.sh
|
||||
elif [[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "rpm" ]] ;then
|
||||
echoColor G "===== install taos-tools when package is lite or client ====="
|
||||
cd ${installPath}
|
||||
sshpass -p ${password} scp -oStrictHostKeyChecking=no -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${version}/community/taosTools-2.1.2-Linux-x64.tar.gz .
|
||||
tar xf taosTools-2.1.2-Linux-x64.tar.gz
|
||||
cd taosTools-2.1.2 && bash install-taostools.sh
|
||||
fi
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ typedef struct SQueryExecMetric {
|
|||
int64_t ctgEnd; // end to parse, us
|
||||
int64_t semanticEnd;
|
||||
int64_t planEnd;
|
||||
int64_t resultReady;
|
||||
int64_t execEnd;
|
||||
int64_t send; // start to send to server, us
|
||||
int64_t rsp; // receive response from server, us
|
||||
|
|
|
@ -76,19 +76,19 @@ static void deregisterRequest(SRequestObj *pRequest) {
|
|||
pRequest->self, pTscObj->id, pRequest->requestId, duration / 1000, num, currentInst);
|
||||
|
||||
if (QUERY_NODE_VNODE_MODIF_STMT == pRequest->stmtType) {
|
||||
tscPerf("insert duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64 "us, exec:%" PRId64 "us",
|
||||
duration, pRequest->metric.syntaxEnd - pRequest->metric.syntaxStart,
|
||||
pRequest->metric.ctgEnd - pRequest->metric.ctgStart,
|
||||
pRequest->metric.semanticEnd - pRequest->metric.ctgEnd,
|
||||
tscPerf("insert duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64
|
||||
"us, exec:%" PRId64 "us",
|
||||
duration, pRequest->metric.syntaxEnd - pRequest->metric.syntaxStart,
|
||||
pRequest->metric.ctgEnd - pRequest->metric.ctgStart, pRequest->metric.semanticEnd - pRequest->metric.ctgEnd,
|
||||
pRequest->metric.execEnd - pRequest->metric.semanticEnd);
|
||||
atomic_add_fetch_64((int64_t *)&pActivity->insertElapsedTime, duration);
|
||||
} else if (QUERY_NODE_SELECT_STMT == pRequest->stmtType) {
|
||||
tscPerf("select duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64 "us, planner:%" PRId64 "us, exec:%" PRId64 "us",
|
||||
duration, pRequest->metric.syntaxEnd - pRequest->metric.syntaxStart,
|
||||
pRequest->metric.ctgEnd - pRequest->metric.ctgStart,
|
||||
pRequest->metric.semanticEnd - pRequest->metric.ctgEnd,
|
||||
tscPerf("select duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64
|
||||
"us, planner:%" PRId64 "us, exec:%" PRId64 "us",
|
||||
duration, pRequest->metric.syntaxEnd - pRequest->metric.syntaxStart,
|
||||
pRequest->metric.ctgEnd - pRequest->metric.ctgStart, pRequest->metric.semanticEnd - pRequest->metric.ctgEnd,
|
||||
pRequest->metric.planEnd - pRequest->metric.semanticEnd,
|
||||
nowUs - pRequest->metric.semanticEnd);
|
||||
pRequest->metric.resultReady - pRequest->metric.planEnd);
|
||||
atomic_add_fetch_64((int64_t *)&pActivity->queryElapsedTime, duration);
|
||||
}
|
||||
|
||||
|
|
|
@ -728,7 +728,7 @@ int32_t handleSubmitExecRes(SRequestObj* pRequest, void* res, SCatalog* pCatalog
|
|||
tFreeSTableMetaRsp(blk->pMeta);
|
||||
taosMemoryFreeClear(blk->pMeta);
|
||||
}
|
||||
|
||||
|
||||
if (NULL == blk->tblFName || 0 == blk->tblFName[0]) {
|
||||
continue;
|
||||
}
|
||||
|
@ -851,6 +851,8 @@ void schedulerExecCb(SExecResult* pResult, void* param, int32_t code) {
|
|||
SRequestObj* pRequest = (SRequestObj*)param;
|
||||
pRequest->code = code;
|
||||
|
||||
pRequest->metric.resultReady = taosGetTimestampUs();
|
||||
|
||||
if (pResult) {
|
||||
memcpy(&pRequest->body.resInfo.execRes, pResult, sizeof(*pResult));
|
||||
}
|
||||
|
|
|
@ -356,6 +356,7 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SArray* pColumns,
|
|||
goto end;
|
||||
}
|
||||
|
||||
pRequest->syncQuery = true;
|
||||
if (!pRequest->pDb) {
|
||||
code = TSDB_CODE_PAR_DB_NOT_SPECIFIED;
|
||||
goto end;
|
||||
|
@ -456,7 +457,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
|
||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, NULL, SCHEMA_ACTION_CREATE_STABLE);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, superTable);
|
||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||
goto end;
|
||||
}
|
||||
info->cost.numOfCreateSTables++;
|
||||
|
@ -492,7 +493,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
|
|||
|
||||
code = smlSendMetaMsg(info, &pName, pColumns, pTags, pTableMeta, action);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, superTable);
|
||||
uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,6 +240,22 @@ static const SSysDbTableSchema variablesSchema[] = {
|
|||
{.name = "value", .bytes = TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema topicSchema[] = {
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
// TODO config
|
||||
};
|
||||
|
||||
|
||||
static const SSysDbTableSchema subscriptionSchema[] = {
|
||||
{.name = "topic_name", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "consumer_group", .bytes = TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysTableMeta infosMeta[] = {
|
||||
{TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true},
|
||||
{TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true},
|
||||
|
@ -260,6 +276,9 @@ static const SSysTableMeta infosMeta[] = {
|
|||
{TSDB_INS_TABLE_VGROUPS, vgroupsSchema, tListLen(vgroupsSchema), true},
|
||||
{TSDB_INS_TABLE_CONFIGS, configSchema, tListLen(configSchema), true},
|
||||
{TSDB_INS_TABLE_DNODE_VARIABLES, variablesSchema, tListLen(variablesSchema), true},
|
||||
{TSDB_INS_TABLE_TOPICS, topicSchema, tListLen(topicSchema), false},
|
||||
{TSDB_INS_TABLE_SUBSCRIPTIONS, subscriptionSchema, tListLen(subscriptionSchema), false},
|
||||
{TSDB_INS_TABLE_STREAMS, streamSchema, tListLen(streamSchema), false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema connectionsSchema[] = {
|
||||
|
@ -272,13 +291,6 @@ static const SSysDbTableSchema connectionsSchema[] = {
|
|||
{.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema topicSchema[] = {
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
{.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
// TODO config
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema consumerSchema[] = {
|
||||
{.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
|
||||
|
@ -292,13 +304,6 @@ static const SSysDbTableSchema consumerSchema[] = {
|
|||
{.name = "rebalance_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema subscriptionSchema[] = {
|
||||
{.name = "topic_name", .bytes = TSDB_TOPIC_FNAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "consumer_group", .bytes = TSDB_CGROUP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
|
||||
{.name = "consumer_id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema offsetSchema[] = {
|
||||
{.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
{.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY, .sysInfo = false},
|
||||
|
@ -345,13 +350,10 @@ static const SSysDbTableSchema appSchema[] = {
|
|||
static const SSysTableMeta perfsMeta[] = {
|
||||
{TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema), false},
|
||||
{TSDB_PERFS_TABLE_QUERIES, querySchema, tListLen(querySchema), false},
|
||||
{TSDB_PERFS_TABLE_TOPICS, topicSchema, tListLen(topicSchema), false},
|
||||
{TSDB_PERFS_TABLE_CONSUMERS, consumerSchema, tListLen(consumerSchema), false},
|
||||
{TSDB_PERFS_TABLE_SUBSCRIPTIONS, subscriptionSchema, tListLen(subscriptionSchema), false},
|
||||
// {TSDB_PERFS_TABLE_OFFSETS, offsetSchema, tListLen(offsetSchema)},
|
||||
{TSDB_PERFS_TABLE_TRANS, transSchema, tListLen(transSchema), false},
|
||||
// {TSDB_PERFS_TABLE_SMAS, smaSchema, tListLen(smaSchema), false},
|
||||
{TSDB_PERFS_TABLE_STREAMS, streamSchema, tListLen(streamSchema), false},
|
||||
{TSDB_PERFS_TABLE_APPS, appSchema, tListLen(appSchema), false}};
|
||||
// clang-format on
|
||||
|
||||
|
|
|
@ -5141,6 +5141,7 @@ static int32_t tEncodeSVDropTbReq(SEncoder *pCoder, const SVDropTbReq *pReq) {
|
|||
if (tStartEncode(pCoder) < 0) return -1;
|
||||
|
||||
if (tEncodeCStr(pCoder, pReq->name) < 0) return -1;
|
||||
if (tEncodeU64(pCoder, pReq->suid) < 0) return -1;
|
||||
if (tEncodeI8(pCoder, pReq->igNotExists) < 0) return -1;
|
||||
|
||||
tEndEncode(pCoder);
|
||||
|
@ -5151,6 +5152,7 @@ static int32_t tDecodeSVDropTbReq(SDecoder *pCoder, SVDropTbReq *pReq) {
|
|||
if (tStartDecode(pCoder) < 0) return -1;
|
||||
|
||||
if (tDecodeCStr(pCoder, &pReq->name) < 0) return -1;
|
||||
if (tDecodeU64(pCoder, &pReq->suid) < 0) return -1;
|
||||
if (tDecodeI8(pCoder, &pReq->igNotExists) < 0) return -1;
|
||||
|
||||
tEndDecode(pCoder);
|
||||
|
|
|
@ -301,7 +301,7 @@ int32_t dmInitServer(SDnode *pDnode) {
|
|||
SDnodeTrans *pTrans = &pDnode->trans;
|
||||
|
||||
SRpcInit rpcInit = {0};
|
||||
strncpy(rpcInit.localFqdn, tsLocalFqdn, strlen(tsLocalFqdn));
|
||||
strncpy(rpcInit.localFqdn, tsLocalFqdn, TSDB_FQDN_LEN);
|
||||
rpcInit.localPort = tsServerPort;
|
||||
rpcInit.label = "DND-S";
|
||||
rpcInit.numOfThreads = tsNumOfRpcThreads;
|
||||
|
|
|
@ -88,7 +88,7 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
|
|||
type = TSDB_MGMT_TABLE_VGROUP;
|
||||
} else if (strncasecmp(name, TSDB_PERFS_TABLE_CONSUMERS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_CONSUMERS;
|
||||
} else if (strncasecmp(name, TSDB_PERFS_TABLE_SUBSCRIPTIONS, len) == 0) {
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_SUBSCRIPTIONS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_SUBSCRIPTIONS;
|
||||
} else if (strncasecmp(name, TSDB_PERFS_TABLE_TRANS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_TRANS;
|
||||
|
@ -102,9 +102,9 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
|
|||
type = TSDB_MGMT_TABLE_QUERIES;
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_VNODES, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_VNODES;
|
||||
} else if (strncasecmp(name, TSDB_PERFS_TABLE_TOPICS, len) == 0) {
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_TOPICS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_TOPICS;
|
||||
} else if (strncasecmp(name, TSDB_PERFS_TABLE_STREAMS, len) == 0) {
|
||||
} else if (strncasecmp(name, TSDB_INS_TABLE_STREAMS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_STREAMS;
|
||||
} else if (strncasecmp(name, TSDB_PERFS_TABLE_APPS, len) == 0) {
|
||||
type = TSDB_MGMT_TABLE_APPS;
|
||||
|
|
|
@ -16,17 +16,17 @@
|
|||
#include "sma.h"
|
||||
#include "tsdb.h"
|
||||
|
||||
static int32_t smaEvalDays(SRetention *r, int8_t precision);
|
||||
static int32_t smaSetKeepCfg(STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int type);
|
||||
static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t precision, int32_t duration);
|
||||
static int32_t smaSetKeepCfg(SVnode *pVnode, STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int type);
|
||||
static int32_t rsmaRestore(SSma *pSma);
|
||||
|
||||
#define SMA_SET_KEEP_CFG(l) \
|
||||
#define SMA_SET_KEEP_CFG(v, l) \
|
||||
do { \
|
||||
SRetention *r = &pCfg->retentions[l]; \
|
||||
pKeepCfg->keep2 = convertTimeFromPrecisionToUnit(r->keep, pCfg->precision, TIME_UNIT_MINUTE); \
|
||||
pKeepCfg->keep0 = pKeepCfg->keep2; \
|
||||
pKeepCfg->keep1 = pKeepCfg->keep2; \
|
||||
pKeepCfg->days = smaEvalDays(r, pCfg->precision); \
|
||||
pKeepCfg->days = smaEvalDays(v, pCfg->retentions, l, pCfg->precision, pCfg->days); \
|
||||
} while (0)
|
||||
|
||||
#define SMA_OPEN_RSMA_IMPL(v, l) \
|
||||
|
@ -38,51 +38,78 @@ static int32_t rsmaRestore(SSma *pSma);
|
|||
} \
|
||||
break; \
|
||||
} \
|
||||
smaSetKeepCfg(&keepCfg, pCfg, TSDB_TYPE_RSMA_L##l); \
|
||||
smaSetKeepCfg(v, &keepCfg, pCfg, TSDB_TYPE_RSMA_L##l); \
|
||||
if (tsdbOpen(v, &SMA_RSMA_TSDB##l(pSma), VNODE_RSMA##l##_DIR, &keepCfg) < 0) { \
|
||||
goto _err; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RETENTION_DAYS_SPLIT_RATIO 10
|
||||
#define RETENTION_DAYS_SPLIT_MIN 1
|
||||
#define RETENTION_DAYS_SPLIT_MAX 30
|
||||
/**
|
||||
* @brief Evaluate days(duration) for rsma level 1/2/3.
|
||||
* 1) level 1: duration from "create database"
|
||||
* 2) level 2/3: duration * (freq/freqL1)
|
||||
* @param pVnode
|
||||
* @param r
|
||||
* @param level
|
||||
* @param precision
|
||||
* @param duration
|
||||
* @return int32_t
|
||||
*/
|
||||
static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t precision, int32_t duration) {
|
||||
int32_t freqDuration = convertTimeFromPrecisionToUnit((r + TSDB_RETENTION_L0)->freq, precision, TIME_UNIT_MINUTE);
|
||||
int32_t keepDuration = convertTimeFromPrecisionToUnit((r + TSDB_RETENTION_L0)->keep, precision, TIME_UNIT_MINUTE);
|
||||
int32_t days = duration; // min
|
||||
|
||||
static int32_t smaEvalDays(SRetention *r, int8_t precision) {
|
||||
int32_t keepDays = convertTimeFromPrecisionToUnit(r->keep, precision, TIME_UNIT_DAY);
|
||||
int32_t freqDays = convertTimeFromPrecisionToUnit(r->freq, precision, TIME_UNIT_DAY);
|
||||
|
||||
int32_t days = keepDays / RETENTION_DAYS_SPLIT_RATIO;
|
||||
if (days <= RETENTION_DAYS_SPLIT_MIN) {
|
||||
days = RETENTION_DAYS_SPLIT_MIN;
|
||||
if (days < freqDays) {
|
||||
days = freqDays + 1;
|
||||
}
|
||||
} else {
|
||||
if (days > RETENTION_DAYS_SPLIT_MAX) {
|
||||
days = RETENTION_DAYS_SPLIT_MAX;
|
||||
}
|
||||
if (days < freqDays) {
|
||||
days = freqDays + 1;
|
||||
}
|
||||
if (days < freqDuration) {
|
||||
days = freqDuration;
|
||||
}
|
||||
return days * 1440;
|
||||
|
||||
if (days > keepDuration) {
|
||||
days = keepDuration;
|
||||
}
|
||||
|
||||
if (level == TSDB_RETENTION_L0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
ASSERT(level >= TSDB_RETENTION_L1 && level <= TSDB_RETENTION_L2);
|
||||
|
||||
freqDuration = convertTimeFromPrecisionToUnit((r + level)->freq, precision, TIME_UNIT_MINUTE);
|
||||
keepDuration = convertTimeFromPrecisionToUnit((r + level)->keep, precision, TIME_UNIT_MINUTE);
|
||||
|
||||
int32_t nFreqTimes = (r + level)->freq / (r + TSDB_RETENTION_L0)->freq;
|
||||
days *= (nFreqTimes > 1 ? nFreqTimes : 1);
|
||||
|
||||
if (days > keepDuration) {
|
||||
days = keepDuration;
|
||||
}
|
||||
|
||||
if (days > TSDB_MAX_DURATION_PER_FILE) {
|
||||
days = TSDB_MAX_DURATION_PER_FILE;
|
||||
}
|
||||
|
||||
if (days < freqDuration) {
|
||||
days = freqDuration;
|
||||
}
|
||||
end:
|
||||
smaInfo("vgId:%d, evaluated duration for level %" PRIi8 " is %d, raw val:%d", TD_VID(pVnode), level + 1, days, duration);
|
||||
return days;
|
||||
}
|
||||
|
||||
int smaSetKeepCfg(STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int type) {
|
||||
int smaSetKeepCfg(SVnode *pVnode, STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int type) {
|
||||
pKeepCfg->precision = pCfg->precision;
|
||||
switch (type) {
|
||||
case TSDB_TYPE_TSMA:
|
||||
ASSERT(0);
|
||||
break;
|
||||
case TSDB_TYPE_RSMA_L0:
|
||||
SMA_SET_KEEP_CFG(0);
|
||||
SMA_SET_KEEP_CFG(pVnode, 0);
|
||||
break;
|
||||
case TSDB_TYPE_RSMA_L1:
|
||||
SMA_SET_KEEP_CFG(1);
|
||||
SMA_SET_KEEP_CFG(pVnode, 1);
|
||||
break;
|
||||
case TSDB_TYPE_RSMA_L2:
|
||||
SMA_SET_KEEP_CFG(2);
|
||||
SMA_SET_KEEP_CFG(pVnode, 2);
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
|
@ -148,11 +175,11 @@ int32_t smaClose(SSma *pSma) {
|
|||
|
||||
/**
|
||||
* @brief rsma env restore
|
||||
*
|
||||
* @param pSma
|
||||
* @param type
|
||||
* @param committedVer
|
||||
* @return int32_t
|
||||
*
|
||||
* @param pSma
|
||||
* @param type
|
||||
* @param committedVer
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t tdRsmaRestore(SSma *pSma, int8_t type, int64_t committedVer) {
|
||||
ASSERT(VND_IS_RSMA(pSma->pVnode));
|
||||
|
|
|
@ -1078,9 +1078,6 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int8_t type, int64_t qTa
|
|||
goto _err;
|
||||
}
|
||||
|
||||
SSmaEnv *pRSmaEnv = pSma->pRSmaEnv;
|
||||
SRSmaStat *pRSmaStat = (SRSmaStat *)SMA_ENV_STAT(pRSmaEnv);
|
||||
|
||||
SRSmaQTaskInfoIter fIter = {0};
|
||||
if (tdRSmaQTaskInfoIterInit(&fIter, &tFile) < 0) {
|
||||
tdRSmaQTaskInfoIterDestroy(&fIter);
|
||||
|
@ -1737,7 +1734,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
ASSERT(1 == atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0));
|
||||
atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0);
|
||||
}
|
||||
}
|
||||
if (type == RSMA_EXEC_COMMIT) {
|
||||
|
@ -1766,7 +1763,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
|
|||
}
|
||||
|
||||
// tdRSmaFetchAllResult(pSma, pInfo, pSubmitArr);
|
||||
ASSERT(1 == atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0));
|
||||
atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0);
|
||||
}
|
||||
}
|
||||
ASSERT(taosQueueItemSize(pInfo->iQueue) == 0);
|
||||
|
|
|
@ -18,12 +18,25 @@
|
|||
int32_t tEncodeSTqHandle(SEncoder* pEncoder, const STqHandle* pHandle) {
|
||||
if (tStartEncode(pEncoder) < 0) return -1;
|
||||
if (tEncodeCStr(pEncoder, pHandle->subKey) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pHandle->fetchMeta) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pHandle->consumerId) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pHandle->snapshotVer) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pHandle->epoch) < 0) return -1;
|
||||
if (tEncodeI8(pEncoder, pHandle->execHandle.subType) < 0) return -1;
|
||||
if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||
if (tEncodeCStr(pEncoder, pHandle->execHandle.execCol.qmsg) < 0) return -1;
|
||||
} else if(pHandle->execHandle.subType == TOPIC_SUB_TYPE__DB){
|
||||
int32_t size = taosHashGetSize(pHandle->execHandle.execDb.pFilterOutTbUid);
|
||||
if (tEncodeI32(pEncoder, size) < 0) return -1;
|
||||
void *pIter = NULL;
|
||||
pIter = taosHashIterate(pHandle->execHandle.execDb.pFilterOutTbUid, pIter);
|
||||
while(pIter){
|
||||
int64_t *tbUid = (int64_t *)taosHashGetKey(pIter, NULL);
|
||||
if (tEncodeI64(pEncoder, *tbUid) < 0) return -1;
|
||||
pIter = taosHashIterate(pHandle->execHandle.execDb.pFilterOutTbUid, pIter);
|
||||
}
|
||||
} else if(pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE){
|
||||
if (tEncodeI64(pEncoder, pHandle->execHandle.execTb.suid) < 0) return -1;
|
||||
}
|
||||
tEndEncode(pEncoder);
|
||||
return pEncoder->pos;
|
||||
|
@ -32,12 +45,25 @@ int32_t tEncodeSTqHandle(SEncoder* pEncoder, const STqHandle* pHandle) {
|
|||
int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle) {
|
||||
if (tStartDecode(pDecoder) < 0) return -1;
|
||||
if (tDecodeCStrTo(pDecoder, pHandle->subKey) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pHandle->fetchMeta) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pHandle->consumerId) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pHandle->snapshotVer) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pHandle->epoch) < 0) return -1;
|
||||
if (tDecodeI8(pDecoder, &pHandle->execHandle.subType) < 0) return -1;
|
||||
if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||
if (tDecodeCStrAlloc(pDecoder, &pHandle->execHandle.execCol.qmsg) < 0) return -1;
|
||||
}else if(pHandle->execHandle.subType == TOPIC_SUB_TYPE__DB){
|
||||
pHandle->execHandle.execDb.pFilterOutTbUid =
|
||||
taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
int32_t size = 0;
|
||||
if (tDecodeI32(pDecoder, &size) < 0) return -1;
|
||||
for(int32_t i = 0; i < size; i++){
|
||||
int64_t tbUid = 0;
|
||||
if (tDecodeI64(pDecoder, &tbUid) < 0) return -1;
|
||||
taosHashPut(pHandle->execHandle.execDb.pFilterOutTbUid, &tbUid, sizeof(int64_t), NULL, 0);
|
||||
}
|
||||
} else if(pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE){
|
||||
if (tDecodeI64(pDecoder, &pHandle->execHandle.execTb.suid) < 0) return -1;
|
||||
}
|
||||
tEndDecode(pDecoder);
|
||||
return 0;
|
||||
|
@ -267,14 +293,28 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
|
|||
ASSERT(scanner);
|
||||
handle.execHandle.pExecReader = qExtractReaderFromStreamScanner(scanner);
|
||||
ASSERT(handle.execHandle.pExecReader);
|
||||
} else {
|
||||
|
||||
} else if (handle.execHandle.subType == TOPIC_SUB_TYPE__DB) {
|
||||
handle.pWalReader = walOpenReader(pTq->pVnode->pWal, NULL);
|
||||
handle.execHandle.execDb.pFilterOutTbUid =
|
||||
taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
// handle.execHandle.pExecReader = tqOpenReader(pTq->pVnode);
|
||||
buildSnapContext(reader.meta, reader.version, 0, handle.execHandle.subType, handle.fetchMeta, (SSnapContext **)(&reader.sContext));
|
||||
handle.execHandle.pExecReader = tqOpenReader(pTq->pVnode);
|
||||
|
||||
buildSnapContext(reader.meta, reader.version, 0, handle.execHandle.subType, handle.fetchMeta, (SSnapContext **)(&reader.sContext));
|
||||
handle.execHandle.task =
|
||||
qCreateQueueExecTaskInfo(NULL, &reader, NULL, NULL);
|
||||
} else if (handle.execHandle.subType == TOPIC_SUB_TYPE__TABLE) {
|
||||
handle.pWalReader = walOpenReader(pTq->pVnode->pWal, NULL);
|
||||
|
||||
SArray* tbUidList = taosArrayInit(0, sizeof(int64_t));
|
||||
vnodeGetCtbIdList(pTq->pVnode, handle.execHandle.execTb.suid, tbUidList);
|
||||
tqDebug("vgId:%d, tq try to get all ctb, suid:%" PRId64, pTq->pVnode->config.vgId, handle.execHandle.execTb.suid);
|
||||
for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) {
|
||||
int64_t tbUid = *(int64_t*)taosArrayGet(tbUidList, i);
|
||||
tqDebug("vgId:%d, idx %d, uid:%" PRId64, TD_VID(pTq->pVnode), i, tbUid);
|
||||
}
|
||||
handle.execHandle.pExecReader = tqOpenReader(pTq->pVnode);
|
||||
tqReaderSetTbUidList(handle.execHandle.pExecReader, tbUidList);
|
||||
taosArrayDestroy(tbUidList);
|
||||
|
||||
buildSnapContext(reader.meta, reader.version, handle.execHandle.execTb.suid, handle.execHandle.subType, handle.fetchMeta, (SSnapContext **)(&reader.sContext));
|
||||
handle.execHandle.task =
|
||||
qCreateQueueExecTaskInfo(NULL, &reader, NULL, NULL);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,162 @@
|
|||
|
||||
#include "tq.h"
|
||||
|
||||
|
||||
bool isValValidForTable(STqHandle* pHandle, SWalCont *pHead){
|
||||
if(pHandle->execHandle.subType != TOPIC_SUB_TYPE__TABLE){
|
||||
return true;
|
||||
}
|
||||
|
||||
int16_t msgType = pHead->msgType;
|
||||
char* body = pHead->body;
|
||||
int32_t bodyLen = pHead->bodyLen;
|
||||
|
||||
int64_t tbSuid = pHandle->execHandle.execTb.suid;
|
||||
int64_t realTbSuid = 0;
|
||||
SDecoder coder;
|
||||
void* data = POINTER_SHIFT(body, sizeof(SMsgHead));
|
||||
int32_t len = bodyLen - sizeof(SMsgHead);
|
||||
tDecoderInit(&coder, data, len);
|
||||
|
||||
if (msgType == TDMT_VND_CREATE_STB || msgType == TDMT_VND_ALTER_STB) {
|
||||
SVCreateStbReq req = {0};
|
||||
if (tDecodeSVCreateStbReq(&coder, &req) < 0) {
|
||||
goto end;
|
||||
}
|
||||
realTbSuid = req.suid;
|
||||
} else if (msgType == TDMT_VND_DROP_STB) {
|
||||
SVDropStbReq req = {0};
|
||||
if (tDecodeSVDropStbReq(&coder, &req) < 0) {
|
||||
goto end;
|
||||
}
|
||||
realTbSuid = req.suid;
|
||||
} else if (msgType == TDMT_VND_CREATE_TABLE) {
|
||||
SVCreateTbBatchReq req = {0};
|
||||
if (tDecodeSVCreateTbBatchReq(&coder, &req) < 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
int32_t needRebuild = 0;
|
||||
SVCreateTbReq* pCreateReq = NULL;
|
||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||
pCreateReq = req.pReqs + iReq;
|
||||
if(pCreateReq->type == TSDB_CHILD_TABLE && pCreateReq->ctb.suid == tbSuid){
|
||||
needRebuild++;
|
||||
}
|
||||
}
|
||||
if(needRebuild == 0){
|
||||
// do nothing
|
||||
}else if(needRebuild == req.nReqs){
|
||||
realTbSuid = tbSuid;
|
||||
}else{
|
||||
realTbSuid = tbSuid;
|
||||
SVCreateTbBatchReq reqNew = {0};
|
||||
reqNew.pArray = taosArrayInit(req.nReqs, sizeof(struct SVCreateTbReq));
|
||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||
pCreateReq = req.pReqs + iReq;
|
||||
if(pCreateReq->type == TSDB_CHILD_TABLE && pCreateReq->ctb.suid == tbSuid){
|
||||
reqNew.nReqs++;
|
||||
taosArrayPush(reqNew.pArray, pCreateReq);
|
||||
}
|
||||
}
|
||||
|
||||
int tlen;
|
||||
int32_t ret = 0;
|
||||
tEncodeSize(tEncodeSVCreateTbBatchReq, &reqNew, tlen, ret);
|
||||
void* buf = taosMemoryMalloc(tlen);
|
||||
if (NULL == buf) {
|
||||
taosArrayDestroy(reqNew.pArray);
|
||||
goto end;
|
||||
}
|
||||
SEncoder coderNew = {0};
|
||||
tEncoderInit(&coderNew, buf, tlen - sizeof(SMsgHead));
|
||||
tEncodeSVCreateTbBatchReq(&coderNew, &reqNew);
|
||||
tEncoderClear(&coderNew);
|
||||
memcpy(pHead->body + sizeof(SMsgHead), buf, tlen);
|
||||
pHead->bodyLen = tlen + sizeof(SMsgHead);
|
||||
taosMemoryFree(buf);
|
||||
taosArrayDestroy(reqNew.pArray);
|
||||
}
|
||||
} else if (msgType == TDMT_VND_ALTER_TABLE) {
|
||||
SVAlterTbReq req = {0};
|
||||
|
||||
if (tDecodeSVAlterTbReq(&coder, &req) < 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
SMetaReader mr = {0};
|
||||
metaReaderInit(&mr, pHandle->execHandle.pExecReader->pVnodeMeta, 0);
|
||||
|
||||
if (metaGetTableEntryByName(&mr, req.tbName) < 0) {
|
||||
metaReaderClear(&mr);
|
||||
goto end;
|
||||
}
|
||||
realTbSuid = mr.me.ctbEntry.suid;
|
||||
metaReaderClear(&mr);
|
||||
} else if (msgType == TDMT_VND_DROP_TABLE) {
|
||||
SVDropTbBatchReq req = {0};
|
||||
|
||||
if (tDecodeSVDropTbBatchReq(&coder, &req) < 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
int32_t needRebuild = 0;
|
||||
SVDropTbReq* pDropReq = NULL;
|
||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||
pDropReq = req.pReqs + iReq;
|
||||
|
||||
if(pDropReq->suid == tbSuid){
|
||||
needRebuild++;
|
||||
}
|
||||
}
|
||||
if(needRebuild == 0){
|
||||
// do nothing
|
||||
}else if(needRebuild == req.nReqs){
|
||||
realTbSuid = tbSuid;
|
||||
}else{
|
||||
realTbSuid = tbSuid;
|
||||
SVDropTbBatchReq reqNew = {0};
|
||||
reqNew.pArray = taosArrayInit(req.nReqs, sizeof(SVDropTbReq));
|
||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||
pDropReq = req.pReqs + iReq;
|
||||
if(pDropReq->suid == tbSuid){
|
||||
reqNew.nReqs++;
|
||||
taosArrayPush(reqNew.pArray, pDropReq);
|
||||
}
|
||||
}
|
||||
|
||||
int tlen;
|
||||
int32_t ret = 0;
|
||||
tEncodeSize(tEncodeSVDropTbBatchReq, &reqNew, tlen, ret);
|
||||
void* buf = taosMemoryMalloc(tlen);
|
||||
if (NULL == buf) {
|
||||
taosArrayDestroy(reqNew.pArray);
|
||||
goto end;
|
||||
}
|
||||
SEncoder coderNew = {0};
|
||||
tEncoderInit(&coderNew, buf, tlen - sizeof(SMsgHead));
|
||||
tEncodeSVDropTbBatchReq(&coderNew, &reqNew);
|
||||
tEncoderClear(&coderNew);
|
||||
memcpy(pHead->body + sizeof(SMsgHead), buf, tlen);
|
||||
pHead->bodyLen = tlen + sizeof(SMsgHead);
|
||||
taosMemoryFree(buf);
|
||||
taosArrayDestroy(reqNew.pArray);
|
||||
}
|
||||
} else if (msgType == TDMT_VND_DELETE) {
|
||||
SDeleteRes req = {0};
|
||||
if (tDecodeDeleteRes(&coder, &req) < 0) {
|
||||
goto end;
|
||||
}
|
||||
realTbSuid = req.suid;
|
||||
} else{
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
end:
|
||||
tDecoderClear(&coder);
|
||||
return tbSuid == realTbSuid;
|
||||
}
|
||||
|
||||
int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** ppCkHead) {
|
||||
int32_t code = 0;
|
||||
taosThreadMutexLock(&pHandle->pWalReader->mutex);
|
||||
|
@ -53,9 +209,11 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHea
|
|||
code = -1;
|
||||
goto END;
|
||||
}
|
||||
*fetchOffset = offset;
|
||||
code = 0;
|
||||
goto END;
|
||||
if(isValValidForTable(pHandle, pHead)){
|
||||
*fetchOffset = offset;
|
||||
code = 0;
|
||||
goto END;
|
||||
}
|
||||
}
|
||||
}
|
||||
code = walSkipFetchBody(pHandle->pWalReader, *ppCkHead);
|
||||
|
|
|
@ -1190,7 +1190,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
|
|||
fmGetFuncExecFuncs(pCtx->functionId, &pCtx->fpSet);
|
||||
} else {
|
||||
char* udfName = pExpr->pExpr->_function.pFunctNode->functionName;
|
||||
strncpy(pCtx->udfName, udfName, strlen(udfName));
|
||||
strncpy(pCtx->udfName, udfName, TSDB_FUNC_NAME_LEN);
|
||||
fmGetUdafExecFuncs(pCtx->functionId, &pCtx->fpSet);
|
||||
}
|
||||
pCtx->fpSet.getEnv(pExpr->pExpr->_function.pFunctNode, &env);
|
||||
|
|
|
@ -3982,8 +3982,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
|||
STableKeyInfo* pKeyInfo = taosArrayGet(pTableListInfo->pTableList, i);
|
||||
qDebug("creating stream task: add table %" PRId64, pKeyInfo->uid);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
pTaskInfo->schemaInfo.qsw = extractQueriedColumnSchema(&pTableScanNode->scan);
|
||||
pOperator = createStreamScanOperatorInfo(pHandle, pTableScanNode, pTagCond, pTaskInfo);
|
||||
|
@ -4449,7 +4449,7 @@ _complete:
|
|||
return code;
|
||||
}
|
||||
|
||||
static void doDestroyTableList(STableListInfo* pTableqinfoList) {
|
||||
void doDestroyTableList(STableListInfo* pTableqinfoList) {
|
||||
taosArrayDestroy(pTableqinfoList->pTableList);
|
||||
taosHashCleanup(pTableqinfoList->map);
|
||||
if (pTableqinfoList->needSortTableByGroupId) {
|
||||
|
|
|
@ -311,6 +311,22 @@ static int32_t translateInOutStr(SFunctionNode* pFunc, char* pErrBuf, int32_t le
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateMinMax(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
if (!IS_TIMESTAMP_TYPE(paraType) && !IS_NUMERIC_TYPE(paraType) && !IS_NULL_TYPE(paraType)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
} else if (IS_NULL_TYPE(paraType)) {
|
||||
paraType = TSDB_DATA_TYPE_BIGINT;
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType){.bytes = tDataTypes[paraType].bytes, .type = paraType};
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateTrimStr(SFunctionNode* pFunc, char* pErrBuf, int32_t len, bool isLtrim) {
|
||||
if (1 != LIST_LENGTH(pFunc->pParameterList)) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
|
@ -698,7 +714,7 @@ static int32_t translateSpread(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
|||
}
|
||||
|
||||
uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
if (!IS_NUMERIC_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) {
|
||||
if (!IS_NUMERIC_TYPE(paraType) && !IS_TIMESTAMP_TYPE(paraType)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
|
@ -713,7 +729,7 @@ static int32_t translateSpreadImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
|||
|
||||
uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
if (isPartial) {
|
||||
if (!IS_NUMERIC_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) {
|
||||
if (!IS_NUMERIC_TYPE(paraType) && !IS_TIMESTAMP_TYPE(paraType)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
pFunc->node.resType = (SDataType){.bytes = getSpreadInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY};
|
||||
|
@ -788,7 +804,7 @@ static int32_t translateElapsedImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
|||
}
|
||||
|
||||
uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
if (TSDB_DATA_TYPE_TIMESTAMP != paraType) {
|
||||
if (!IS_TIMESTAMP_TYPE(paraType)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
|
@ -1634,7 +1650,7 @@ static int32_t translateDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
|||
|
||||
uint8_t colType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
if (!IS_SIGNED_NUMERIC_TYPE(colType) && !IS_FLOAT_TYPE(colType) && TSDB_DATA_TYPE_BOOL != colType &&
|
||||
TSDB_DATA_TYPE_TIMESTAMP != colType) {
|
||||
!IS_TIMESTAMP_TYPE(colType)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
|
@ -1660,7 +1676,7 @@ static int32_t translateDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
|||
}
|
||||
|
||||
uint8_t resType;
|
||||
if (IS_SIGNED_NUMERIC_TYPE(colType) || TSDB_DATA_TYPE_BOOL == colType || TSDB_DATA_TYPE_TIMESTAMP == colType) {
|
||||
if (IS_SIGNED_NUMERIC_TYPE(colType) || IS_TIMESTAMP_TYPE(colType) || TSDB_DATA_TYPE_BOOL == colType) {
|
||||
resType = TSDB_DATA_TYPE_BIGINT;
|
||||
} else {
|
||||
resType = TSDB_DATA_TYPE_DOUBLE;
|
||||
|
@ -1825,7 +1841,7 @@ static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t l
|
|||
|
||||
// param0
|
||||
uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
if (!IS_INTEGER_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) {
|
||||
if (!IS_INTEGER_TYPE(paraType) && !IS_TIMESTAMP_TYPE(paraType)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
|
@ -1878,7 +1894,7 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
|
|||
|
||||
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
|
||||
uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type;
|
||||
if ((!IS_STR_DATA_TYPE(para1Type) && !IS_INTEGER_TYPE(para1Type) && TSDB_DATA_TYPE_TIMESTAMP != para1Type) ||
|
||||
if ((!IS_STR_DATA_TYPE(para1Type) && !IS_INTEGER_TYPE(para1Type) && !IS_TIMESTAMP_TYPE(para1Type)) ||
|
||||
!IS_INTEGER_TYPE(para2Type)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
@ -1911,7 +1927,7 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
|
|||
|
||||
for (int32_t i = 0; i < 2; ++i) {
|
||||
uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, i))->resType.type;
|
||||
if (!IS_STR_DATA_TYPE(paraType) && !IS_INTEGER_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) {
|
||||
if (!IS_STR_DATA_TYPE(paraType) && !IS_INTEGER_TYPE(paraType) && !IS_TIMESTAMP_TYPE(paraType)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
}
|
||||
|
@ -2060,7 +2076,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "min",
|
||||
.type = FUNCTION_TYPE_MIN,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_SELECT_FUNC,
|
||||
.translateFunc = translateInOutNum,
|
||||
.translateFunc = translateMinMax,
|
||||
.dataRequiredFunc = statisDataRequired,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = minmaxFunctionSetup,
|
||||
|
@ -2075,7 +2091,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
|||
.name = "max",
|
||||
.type = FUNCTION_TYPE_MAX,
|
||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_SELECT_FUNC,
|
||||
.translateFunc = translateInOutNum,
|
||||
.translateFunc = translateMinMax,
|
||||
.dataRequiredFunc = statisDataRequired,
|
||||
.getEnvFunc = getMinmaxFuncEnv,
|
||||
.initFunc = minmaxFunctionSetup,
|
||||
|
|
|
@ -1160,6 +1160,7 @@ static int32_t findRowIndex(int32_t start, int32_t num, SColumnInfoData* pCol, c
|
|||
}
|
||||
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
||||
|
@ -1203,7 +1204,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
|||
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock);
|
||||
}
|
||||
} else {
|
||||
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||
if (IS_SIGNED_NUMERIC_TYPE(type) || IS_TIMESTAMP_TYPE(type)) {
|
||||
int64_t prev = 0;
|
||||
GET_TYPED_DATA(prev, int64_t, type, &pBuf->v);
|
||||
|
||||
|
@ -1215,7 +1216,6 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
|||
pBuf->tuplePos = saveTupleData(pCtx, index, pCtx->pSrcBlock);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||
uint64_t prev = 0;
|
||||
GET_TYPED_DATA(prev, uint64_t, type, &pBuf->v);
|
||||
|
@ -1263,7 +1263,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
|||
int32_t start = pInput->startRowIndex;
|
||||
int32_t numOfRows = pInput->numOfRows;
|
||||
|
||||
if (IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_BOOL) {
|
||||
if (IS_SIGNED_NUMERIC_TYPE(type) || IS_TIMESTAMP_TYPE(type) || type == TSDB_DATA_TYPE_BOOL) {
|
||||
if (type == TSDB_DATA_TYPE_TINYINT || type == TSDB_DATA_TYPE_BOOL) {
|
||||
int8_t* pData = (int8_t*)pCol->pData;
|
||||
int8_t* val = (int8_t*)&pBuf->v;
|
||||
|
@ -1357,7 +1357,8 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
|
|||
|
||||
numOfElems += 1;
|
||||
}
|
||||
} else if (type == TSDB_DATA_TYPE_BIGINT) {
|
||||
} else if (type == TSDB_DATA_TYPE_BIGINT ||
|
||||
type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
int64_t* pData = (int64_t*)pCol->pData;
|
||||
int64_t* val = (int64_t*)&pBuf->v;
|
||||
|
||||
|
|
|
@ -101,6 +101,14 @@ bool fmIsBuiltinFunc(const char* pFunc) {
|
|||
return NULL != taosHashGet(gFunMgtService.pFuncNameHashTable, pFunc, strlen(pFunc));
|
||||
}
|
||||
|
||||
EFunctionType fmGetFuncType(const char* pFunc) {
|
||||
void* pVal = taosHashGet(gFunMgtService.pFuncNameHashTable, pFunc, strlen(pFunc));
|
||||
if (NULL != pVal) {
|
||||
return funcMgtBuiltins[*(int32_t*)pVal].type;
|
||||
}
|
||||
return FUNCTION_TYPE_UDF;
|
||||
}
|
||||
|
||||
EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) {
|
||||
if (fmIsUserDefinedFunc(pFunc->funcId) || pFunc->funcId < 0 || pFunc->funcId >= funcMgtBuiltinsNum) {
|
||||
return FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||
|
|
|
@ -81,7 +81,7 @@ static int32_t udfSpawnUdfd(SUdfdData* pData) {
|
|||
taosDirName(path);
|
||||
#endif
|
||||
} else {
|
||||
strncpy(path, tsProcPath, strlen(tsProcPath));
|
||||
strncpy(path, tsProcPath, PATH_MAX);
|
||||
taosDirName(path);
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
|
|
|
@ -453,7 +453,7 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
|||
goto _return;
|
||||
}
|
||||
taosCloseFile(&file);
|
||||
strncpy(udf->path, path, strlen(path));
|
||||
strncpy(udf->path, path, PATH_MAX);
|
||||
tFreeSFuncInfo(pFuncInfo);
|
||||
taosArrayDestroy(retrieveRsp.pFuncInfos);
|
||||
msgInfo->code = 0;
|
||||
|
@ -566,17 +566,17 @@ int32_t udfdLoadUdf(char *udfName, SUdf *udf) {
|
|||
uv_dlsym(&udf->lib, processFuncName, (void **)(&udf->aggProcFunc));
|
||||
char startFuncName[TSDB_FUNC_NAME_LEN + 6] = {0};
|
||||
char *startSuffix = "_start";
|
||||
strncpy(startFuncName, processFuncName, strlen(processFuncName));
|
||||
strncpy(startFuncName, processFuncName, sizeof(startFuncName));
|
||||
strncat(startFuncName, startSuffix, strlen(startSuffix));
|
||||
uv_dlsym(&udf->lib, startFuncName, (void **)(&udf->aggStartFunc));
|
||||
char finishFuncName[TSDB_FUNC_NAME_LEN + 7] = {0};
|
||||
char *finishSuffix = "_finish";
|
||||
strncpy(finishFuncName, processFuncName, strlen(processFuncName));
|
||||
strncpy(finishFuncName, processFuncName, sizeof(finishFuncName));
|
||||
strncat(finishFuncName, finishSuffix, strlen(finishSuffix));
|
||||
uv_dlsym(&udf->lib, finishFuncName, (void **)(&udf->aggFinishFunc));
|
||||
char mergeFuncName[TSDB_FUNC_NAME_LEN + 6] = {0};
|
||||
char *mergeSuffix = "_merge";
|
||||
strncpy(finishFuncName, processFuncName, strlen(processFuncName));
|
||||
strncpy(finishFuncName, processFuncName, sizeof(finishFuncName));
|
||||
strncat(finishFuncName, mergeSuffix, strlen(mergeSuffix));
|
||||
uv_dlsym(&udf->lib, finishFuncName, (void **)(&udf->aggMergeFunc));
|
||||
}
|
||||
|
|
|
@ -171,6 +171,7 @@ TExeCond tCompare(__compar_fn_t func, int8_t cmptype, void* a, void* b, int8_t d
|
|||
return tDoCompare(func, cmptype, &va, &vb);
|
||||
}
|
||||
assert(0);
|
||||
return BREAK;
|
||||
#endif
|
||||
}
|
||||
TExeCond tDoCompare(__compar_fn_t func, int8_t comparType, void* a, void* b) {
|
||||
|
|
|
@ -39,7 +39,8 @@ static void idxGenLRUKey(char* buf, const char* path, int32_t blockId) {
|
|||
}
|
||||
static int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) {
|
||||
if (ctx->type == TFILE) {
|
||||
assert(len == taosWriteFile(ctx->file.pFile, buf, len));
|
||||
int nwr = taosWriteFile(ctx->file.pFile, buf, len);
|
||||
assert(nwr == len);
|
||||
} else {
|
||||
memcpy(ctx->mem.buf + ctx->offset, buf, len);
|
||||
}
|
||||
|
|
|
@ -97,16 +97,23 @@ typedef struct SCollectMetaKeyCxt {
|
|||
|
||||
typedef struct SCollectMetaKeyFromExprCxt {
|
||||
SCollectMetaKeyCxt* pComCxt;
|
||||
bool hasLastRow;
|
||||
int32_t errCode;
|
||||
} SCollectMetaKeyFromExprCxt;
|
||||
|
||||
static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt);
|
||||
|
||||
static EDealRes collectMetaKeyFromFunction(SCollectMetaKeyFromExprCxt* pCxt, SFunctionNode* pFunc) {
|
||||
if (fmIsBuiltinFunc(pFunc->functionName)) {
|
||||
return DEAL_RES_CONTINUE;
|
||||
switch (fmGetFuncType(pFunc->functionName)) {
|
||||
case FUNCTION_TYPE_LAST_ROW:
|
||||
pCxt->hasLastRow = true;
|
||||
break;
|
||||
case FUNCTION_TYPE_UDF:
|
||||
pCxt->errCode = reserveUdfInCache(pFunc->functionName, pCxt->pComCxt->pMetaCache);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
pCxt->errCode = reserveUdfInCache(pFunc->functionName, pCxt->pComCxt->pMetaCache);
|
||||
return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
|
@ -136,9 +143,6 @@ static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, const c
|
|||
if (TSDB_CODE_SUCCESS == code && (0 == strcmp(pTable, TSDB_INS_TABLE_DNODE_VARIABLES))) {
|
||||
code = reserveDnodeRequiredInCache(pCxt->pMetaCache);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pDb, pCxt->pMetaCache);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -185,9 +189,19 @@ static int32_t collectMetaKeyFromSetOperator(SCollectMetaKeyCxt* pCxt, SSetOpera
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t reserveDbCfgForLastRow(SCollectMetaKeyCxt* pCxt, SNode* pTable) {
|
||||
if (NULL == pTable || QUERY_NODE_REAL_TABLE != nodeType(pTable)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
return reserveDbCfgInCache(pCxt->pParseCxt->acctId, ((SRealTableNode*)pTable)->table.dbName, pCxt->pMetaCache);
|
||||
}
|
||||
|
||||
static int32_t collectMetaKeyFromSelect(SCollectMetaKeyCxt* pCxt, SSelectStmt* pStmt) {
|
||||
SCollectMetaKeyFromExprCxt cxt = {.pComCxt = pCxt, .errCode = TSDB_CODE_SUCCESS};
|
||||
SCollectMetaKeyFromExprCxt cxt = {.pComCxt = pCxt, .hasLastRow = false, .errCode = TSDB_CODE_SUCCESS};
|
||||
nodesWalkSelectStmt(pStmt, SQL_CLAUSE_FROM, collectMetaKeyFromExprImpl, &cxt);
|
||||
if (TSDB_CODE_SUCCESS == cxt.errCode && cxt.hasLastRow) {
|
||||
cxt.errCode = reserveDbCfgForLastRow(pCxt, pStmt->pFromTable);
|
||||
}
|
||||
return cxt.errCode;
|
||||
}
|
||||
|
||||
|
@ -365,7 +379,7 @@ static int32_t collectMetaKeyFromShowStables(SCollectMetaKeyCxt* pCxt, SShowStmt
|
|||
}
|
||||
|
||||
static int32_t collectMetaKeyFromShowStreams(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_STREAMS,
|
||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_STREAMS,
|
||||
pCxt->pMetaCache);
|
||||
}
|
||||
|
||||
|
@ -411,7 +425,7 @@ static int32_t collectMetaKeyFromShowVgroups(SCollectMetaKeyCxt* pCxt, SShowStmt
|
|||
}
|
||||
|
||||
static int32_t collectMetaKeyFromShowTopics(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_TOPICS,
|
||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TOPICS,
|
||||
pCxt->pMetaCache);
|
||||
}
|
||||
|
||||
|
@ -506,7 +520,7 @@ static int32_t collectMetaKeyFromShowBlockDist(SCollectMetaKeyCxt* pCxt, SShowTa
|
|||
}
|
||||
|
||||
static int32_t collectMetaKeyFromShowSubscriptions(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) {
|
||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_SUBSCRIPTIONS,
|
||||
return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_SUBSCRIPTIONS,
|
||||
pCxt->pMetaCache);
|
||||
}
|
||||
|
||||
|
|
|
@ -142,8 +142,8 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
|
|||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_STREAMS_STMT,
|
||||
.pDbName = TSDB_PERFORMANCE_SCHEMA_DB,
|
||||
.pTableName = TSDB_PERFS_TABLE_STREAMS,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_STREAMS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"stream_name"}
|
||||
},
|
||||
|
@ -184,8 +184,8 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
|
|||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_TOPICS_STMT,
|
||||
.pDbName = TSDB_PERFORMANCE_SCHEMA_DB,
|
||||
.pTableName = TSDB_PERFS_TABLE_TOPICS,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_TOPICS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"topic_name"}
|
||||
},
|
||||
|
@ -240,8 +240,8 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
|
|||
},
|
||||
{
|
||||
.showType = QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT,
|
||||
.pDbName = TSDB_PERFORMANCE_SCHEMA_DB,
|
||||
.pTableName = TSDB_PERFS_TABLE_SUBSCRIPTIONS,
|
||||
.pDbName = TSDB_INFORMATION_SCHEMA_DB,
|
||||
.pTableName = TSDB_INS_TABLE_SUBSCRIPTIONS,
|
||||
.numOfShowCols = 1,
|
||||
.pShowCols = {"*"}
|
||||
},
|
||||
|
@ -2160,15 +2160,16 @@ static int32_t setTableIndex(STranslateContext* pCxt, SName* pName, SRealTableNo
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t setTableCacheLastMode(STranslateContext* pCxt, SName* pName, SRealTableNode* pRealTable) {
|
||||
if (TSDB_SYSTEM_TABLE == pRealTable->pMeta->tableType) {
|
||||
static int32_t setTableCacheLastMode(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
if (!pSelect->hasLastRowFunc || QUERY_NODE_REAL_TABLE != nodeType(pSelect->pFromTable)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SDbCfgInfo dbCfg = {0};
|
||||
int32_t code = getDBCfg(pCxt, pRealTable->table.dbName, &dbCfg);
|
||||
SRealTableNode* pTable = (SRealTableNode*)pSelect->pFromTable;
|
||||
SDbCfgInfo dbCfg = {0};
|
||||
int32_t code = getDBCfg(pCxt, pTable->table.dbName, &dbCfg);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pRealTable->cacheLastMode = dbCfg.cacheLast;
|
||||
pTable->cacheLastMode = dbCfg.cacheLast;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -2192,9 +2193,6 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = setTableIndex(pCxt, &name, pRealTable);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = setTableCacheLastMode(pCxt, &name, pRealTable);
|
||||
}
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pRealTable->table.precision = pRealTable->pMeta->tableInfo.precision;
|
||||
|
@ -2273,10 +2271,14 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
|
|||
if (QUERY_NODE_COLUMN == nodeType(pExpr)) {
|
||||
SColumnNode* pCol = (SColumnNode*)pExpr;
|
||||
len = snprintf(buf, sizeof(buf), "%s(%s.%s)", pSrcFunc->functionName, pCol->tableAlias, pCol->colName);
|
||||
strncpy(pFunc->node.aliasName, buf, TMIN(len, sizeof(pFunc->node.aliasName) - 1));
|
||||
len = snprintf(buf, sizeof(buf), "%s(%s)", pSrcFunc->functionName, pCol->colName);
|
||||
strncpy(pFunc->node.userAlias, buf, TMIN(len, sizeof(pFunc->node.userAlias) - 1));
|
||||
} else {
|
||||
len = snprintf(buf, sizeof(buf), "%s(%s)", pSrcFunc->functionName, pExpr->aliasName);
|
||||
strncpy(pFunc->node.aliasName, buf, TMIN(len, sizeof(pFunc->node.aliasName) - 1));
|
||||
strncpy(pFunc->node.userAlias, buf, TMIN(len, sizeof(pFunc->node.userAlias) - 1));
|
||||
}
|
||||
strncpy(pFunc->node.aliasName, buf, TMIN(len, sizeof(pFunc->node.aliasName) - 1));
|
||||
|
||||
return (SNode*)pFunc;
|
||||
}
|
||||
|
@ -3140,6 +3142,9 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = replaceOrderByAliasForSelect(pCxt, pSelect);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = setTableCacheLastMode(pCxt, pSelect);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -6403,8 +6408,8 @@ typedef struct SVgroupDropTableBatch {
|
|||
char dbName[TSDB_DB_NAME_LEN];
|
||||
} SVgroupDropTableBatch;
|
||||
|
||||
static void addDropTbReqIntoVgroup(SHashObj* pVgroupHashmap, SDropTableClause* pClause, SVgroupInfo* pVgInfo) {
|
||||
SVDropTbReq req = {.name = pClause->tableName, .igNotExists = pClause->ignoreNotExists};
|
||||
static void addDropTbReqIntoVgroup(SHashObj* pVgroupHashmap, SDropTableClause* pClause, SVgroupInfo* pVgInfo, uint64_t suid) {
|
||||
SVDropTbReq req = {.name = pClause->tableName, .suid = suid, .igNotExists = pClause->ignoreNotExists};
|
||||
SVgroupDropTableBatch* pTableBatch = taosHashGet(pVgroupHashmap, &pVgInfo->vgId, sizeof(pVgInfo->vgId));
|
||||
if (NULL == pTableBatch) {
|
||||
SVgroupDropTableBatch tBatch = {0};
|
||||
|
@ -6445,7 +6450,7 @@ static int32_t buildDropTableVgroupHashmap(STranslateContext* pCxt, SDropTableCl
|
|||
code = getTableHashVgroup(pCxt, pClause->dbName, pClause->tableName, &info);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
addDropTbReqIntoVgroup(pVgroupHashmap, pClause, &info);
|
||||
addDropTbReqIntoVgroup(pVgroupHashmap, pClause, &info, pTableMeta->suid);
|
||||
}
|
||||
|
||||
over:
|
||||
|
|
|
@ -137,7 +137,7 @@ void generatePerformanceSchema(MockCatalogService* mcs) {
|
|||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_STREAMS, TSDB_SYSTEM_TABLE, 1)
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_STREAMS, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ void generatePerformanceSchema(MockCatalogService* mcs) {
|
|||
}
|
||||
{
|
||||
ITableBuilder& builder =
|
||||
mcs->createTableBuilder(TSDB_PERFORMANCE_SCHEMA_DB, TSDB_PERFS_TABLE_SUBSCRIPTIONS, TSDB_SYSTEM_TABLE, 1)
|
||||
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_SUBSCRIPTIONS, TSDB_SYSTEM_TABLE, 1)
|
||||
.addColumn("stream_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN);
|
||||
builder.done();
|
||||
}
|
||||
|
|
|
@ -163,6 +163,7 @@ int64_t syncIndexMgrGetStartTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pR
|
|||
}
|
||||
}
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void syncIndexMgrSetRecvTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId, int64_t recvTime) {
|
||||
|
@ -190,6 +191,7 @@ int64_t syncIndexMgrGetRecvTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRa
|
|||
}
|
||||
}
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// for debug -------------------
|
||||
|
@ -245,4 +247,5 @@ SyncTerm syncIndexMgrGetTerm(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftI
|
|||
}
|
||||
}
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
|
@ -583,7 +583,7 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap
|
|||
&(pReceiver->snapshot));
|
||||
if (code != 0) {
|
||||
syncNodeErrorLog(pReceiver->pSyncNode, "snapshot stop writer true error");
|
||||
ASSERT(0);
|
||||
// ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
pReceiver->pWriter = NULL;
|
||||
|
|
|
@ -91,16 +91,16 @@ int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg) {
|
|||
} else if (pMsg->timeoutType == SYNC_TIMEOUT_ELECTION) {
|
||||
if (atomic_load_64(&ths->electTimerLogicClockUser) <= pMsg->logicClock) {
|
||||
++(ths->electTimerCounter);
|
||||
sInfo("vgId:%d, sync timeout, type:election count:%d, electTimerLogicClockUser:%ld", ths->vgId,
|
||||
ths->electTimerCounter, ths->electTimerLogicClockUser);
|
||||
sTrace("vgId:%d, sync timer, type:election count:%d, electTimerLogicClockUser:%ld", ths->vgId,
|
||||
ths->electTimerCounter, ths->electTimerLogicClockUser);
|
||||
syncNodeElect(ths);
|
||||
}
|
||||
|
||||
} else if (pMsg->timeoutType == SYNC_TIMEOUT_HEARTBEAT) {
|
||||
if (atomic_load_64(&ths->heartbeatTimerLogicClockUser) <= pMsg->logicClock) {
|
||||
++(ths->heartbeatTimerCounter);
|
||||
sInfo("vgId:%d, sync timeout, type:replicate count:%d, heartbeatTimerLogicClockUser:%ld", ths->vgId,
|
||||
ths->heartbeatTimerCounter, ths->heartbeatTimerLogicClockUser);
|
||||
sTrace("vgId:%d, sync timer, type:replicate count:%d, heartbeatTimerLogicClockUser:%ld", ths->vgId,
|
||||
ths->heartbeatTimerCounter, ths->heartbeatTimerLogicClockUser);
|
||||
syncNodeReplicate(ths, true);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "taoserror.h"
|
||||
#include "tlog.h"
|
||||
|
||||
// clang-format on
|
||||
|
||||
#define HTTP_RECV_BUF_SIZE 1024
|
||||
|
||||
|
@ -29,7 +30,7 @@ typedef struct SHttpClient {
|
|||
uv_tcp_t tcp;
|
||||
uv_write_t req;
|
||||
uv_buf_t* wbuf;
|
||||
char *rbuf;
|
||||
char* rbuf;
|
||||
char* addr;
|
||||
uint16_t port;
|
||||
} SHttpClient;
|
||||
|
@ -130,37 +131,36 @@ static void destroyHttpClient(SHttpClient* cli) {
|
|||
taosMemoryFree(cli->rbuf);
|
||||
taosMemoryFree(cli->addr);
|
||||
taosMemoryFree(cli);
|
||||
|
||||
}
|
||||
static void clientCloseCb(uv_handle_t* handle) {
|
||||
SHttpClient* cli = handle->data;
|
||||
destroyHttpClient(cli);
|
||||
}
|
||||
static void clientAllocBuffCb(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) {
|
||||
SHttpClient* cli = handle->data;
|
||||
buf->base = cli->rbuf;
|
||||
buf->len = HTTP_RECV_BUF_SIZE;
|
||||
static void clientAllocBuffCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) {
|
||||
SHttpClient* cli = handle->data;
|
||||
buf->base = cli->rbuf;
|
||||
buf->len = HTTP_RECV_BUF_SIZE;
|
||||
}
|
||||
static void clientRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t *buf) {
|
||||
SHttpClient* cli = handle->data;
|
||||
static void clientRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) {
|
||||
SHttpClient* cli = handle->data;
|
||||
if (nread < 0) {
|
||||
uError("http-report recv error:%s", uv_err_name(nread));
|
||||
} else {
|
||||
uTrace("http-report succ to recv %d bytes, just ignore it", nread);
|
||||
}
|
||||
uv_close((uv_handle_t*)&cli->tcp, clientCloseCb);
|
||||
}
|
||||
}
|
||||
static void clientSentCb(uv_write_t* req, int32_t status) {
|
||||
SHttpClient* cli = req->data;
|
||||
if (status != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(status);
|
||||
uError("http-report failed to send data %s", uv_strerror(status));
|
||||
uv_close((uv_handle_t*)&cli->tcp, clientCloseCb);
|
||||
return;
|
||||
return;
|
||||
} else {
|
||||
uTrace("http-report succ to send data");
|
||||
}
|
||||
uv_read_start((uv_stream_t *)&cli->tcp, clientAllocBuffCb, clientRecvCb);
|
||||
uv_read_start((uv_stream_t*)&cli->tcp, clientAllocBuffCb, clientRecvCb);
|
||||
}
|
||||
static void clientConnCb(uv_connect_t* req, int32_t status) {
|
||||
SHttpClient* cli = req->data;
|
||||
|
@ -212,7 +212,7 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32
|
|||
cli->tcp.data = cli;
|
||||
cli->req.data = cli;
|
||||
cli->wbuf = wb;
|
||||
cli->rbuf = taosMemoryCalloc(1, HTTP_RECV_BUF_SIZE);
|
||||
cli->rbuf = taosMemoryCalloc(1, HTTP_RECV_BUF_SIZE);
|
||||
cli->addr = tstrdup(server);
|
||||
cli->port = port;
|
||||
|
||||
|
@ -233,4 +233,3 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32
|
|||
uv_loop_close(loop);
|
||||
return terrno;
|
||||
}
|
||||
// clang-format on
|
||||
|
|
|
@ -43,7 +43,7 @@ void* rpcOpen(const SRpcInit* pInit) {
|
|||
return NULL;
|
||||
}
|
||||
if (pInit->label) {
|
||||
tstrncpy(pRpc->label, pInit->label, strlen(pInit->label) + 1);
|
||||
tstrncpy(pRpc->label, pInit->label, TSDB_LABEL_LEN);
|
||||
}
|
||||
// register callback handle
|
||||
pRpc->cfp = pInit->cfp;
|
||||
|
|
|
@ -906,23 +906,30 @@ static void uvDestroyConn(uv_handle_t* handle) {
|
|||
}
|
||||
}
|
||||
static void uvPipeListenCb(uv_stream_t* handle, int status) {
|
||||
ASSERT(status == 0);
|
||||
if (status != 0) {
|
||||
tError("server failed to init pipe");
|
||||
return;
|
||||
}
|
||||
|
||||
SServerObj* srv = container_of(handle, SServerObj, pipeListen);
|
||||
uv_pipe_t* pipe = &(srv->pipe[srv->numOfWorkerReady][0]);
|
||||
ASSERT(0 == uv_pipe_init(srv->loop, pipe, 1));
|
||||
ASSERT(0 == uv_accept((uv_stream_t*)&srv->pipeListen, (uv_stream_t*)pipe));
|
||||
|
||||
ASSERT(1 == uv_is_readable((uv_stream_t*)pipe));
|
||||
ASSERT(1 == uv_is_writable((uv_stream_t*)pipe));
|
||||
ASSERT(0 == uv_is_closing((uv_handle_t*)pipe));
|
||||
int ret = uv_pipe_init(srv->loop, pipe, 1);
|
||||
assert(ret == 0);
|
||||
|
||||
ret = uv_accept((uv_stream_t*)&srv->pipeListen, (uv_stream_t*)pipe);
|
||||
assert(ret == 0);
|
||||
|
||||
ret = uv_is_readable((uv_stream_t*)pipe);
|
||||
assert(ret == 1);
|
||||
|
||||
ret = uv_is_writable((uv_stream_t*)pipe);
|
||||
assert(ret == 1);
|
||||
|
||||
ret = uv_is_closing((uv_handle_t*)pipe);
|
||||
assert(ret == 0);
|
||||
|
||||
srv->numOfWorkerReady++;
|
||||
|
||||
// ASSERT(0 == uv_listen((uv_stream_t*)&ctx.send.tcp, 512, uvOnAcceptCb));
|
||||
|
||||
// r = uv_read_start((uv_stream_t*)&ctx.channel, alloc_cb, read_cb);
|
||||
// ASSERT(r == 0);
|
||||
}
|
||||
|
||||
void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle) {
|
||||
|
@ -937,7 +944,9 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
|
|||
srv->port = port;
|
||||
uv_loop_init(srv->loop);
|
||||
|
||||
assert(0 == uv_pipe_init(srv->loop, &srv->pipeListen, 0));
|
||||
int ret = uv_pipe_init(srv->loop, &srv->pipeListen, 0);
|
||||
assert(ret == 0);
|
||||
|
||||
#ifdef WINDOWS
|
||||
char pipeName[64];
|
||||
snprintf(pipeName, sizeof(pipeName), "\\\\?\\pipe\\trans.rpc.%p-" PRIu64, taosSafeRand(), GetCurrentProcessId());
|
||||
|
@ -946,8 +955,11 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
|
|||
snprintf(pipeName, sizeof(pipeName), "%s%spipe.trans.rpc.%08X-" PRIu64, tsTempDir, TD_DIRSEP, taosSafeRand(),
|
||||
taosGetSelfPthreadId());
|
||||
#endif
|
||||
assert(0 == uv_pipe_bind(&srv->pipeListen, pipeName));
|
||||
assert(0 == uv_listen((uv_stream_t*)&srv->pipeListen, SOMAXCONN, uvPipeListenCb));
|
||||
ret = uv_pipe_bind(&srv->pipeListen, pipeName);
|
||||
assert(ret == 0);
|
||||
|
||||
ret = uv_listen((uv_stream_t*)&srv->pipeListen, SOMAXCONN, uvPipeListenCb);
|
||||
assert(ret == 0);
|
||||
|
||||
for (int i = 0; i < srv->numOfThreads; i++) {
|
||||
SWorkThrd* thrd = (SWorkThrd*)taosMemoryCalloc(1, sizeof(SWorkThrd));
|
||||
|
|
|
@ -372,7 +372,7 @@ int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead) {
|
|||
int32_t walSkipFetchBody(SWalReader *pRead, const SWalCkHead *pHead) {
|
||||
int64_t code;
|
||||
|
||||
ASSERT(pRead->curVersion == pHead->head.version);
|
||||
// ASSERT(pRead->curVersion == pHead->head.version);
|
||||
|
||||
code = taosLSeekFile(pRead->pLogFile, pHead->head.bodyLen, SEEK_CUR);
|
||||
if (code < 0) {
|
||||
|
|
|
@ -201,6 +201,7 @@ void *taosbsearch(const void *key, const void *base, int32_t nmemb, int32_t size
|
|||
return (c > 0) ? p : (midx > 0 ? p - size : NULL);
|
||||
} else {
|
||||
ASSERT(0);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -244,6 +244,7 @@ int32_t compareJsonVal(const void *pLeft, const void *pRight) {
|
|||
return 0;
|
||||
}else{
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -621,7 +621,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_SCHEMA, "Rsma invalid schema
|
|||
|
||||
//index
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_INDEX_REBUILDING, "Index is rebuilding")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_INDEX_REBUILDING, "Invalid index file")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_INDEX_INVALID_FILE, "Index file is invalid")
|
||||
|
||||
//tmq
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_INVALID_MSG, "Invalid message")
|
||||
|
|
|
@ -446,7 +446,10 @@ static inline void taosPrintLogImp(ELogLevel level, int32_t dflag, const char *b
|
|||
}
|
||||
|
||||
if (dflag & DEBUG_SCREEN) {
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-result"
|
||||
write(1, buffer, (uint32_t)len);
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
char version[12] = "${TD_VER_NUMBER}";
|
||||
char version[64] = "${TD_VER_NUMBER}";
|
||||
char compatible_version[12] = "${TD_VER_COMPATIBLE}";
|
||||
char gitinfo[48] = "${TD_VER_GIT}";
|
||||
char buildinfo[64] = "Built at ${TD_VER_DATE}";
|
||||
|
|
|
@ -11,15 +11,19 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from logging.config import dictConfig
|
||||
import sys
|
||||
import os
|
||||
from util.log import *
|
||||
from util.cases import *
|
||||
from util.sql import *
|
||||
from util.dnodes import *
|
||||
import string
|
||||
import random
|
||||
|
||||
|
||||
class TDTestCase:
|
||||
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
|
@ -47,12 +51,19 @@ class TDTestCase:
|
|||
return ""
|
||||
return paths[0]
|
||||
|
||||
def generateString(self, length):
|
||||
chars = string.ascii_uppercase + string.ascii_lowercase
|
||||
v = ""
|
||||
for i in range(length):
|
||||
v += random.choice(chars)
|
||||
return v
|
||||
|
||||
def run(self):
|
||||
if not os.path.exists("./taosdumptest/tmp"):
|
||||
os.makedirs("./taosdumptest/tmp")
|
||||
else:
|
||||
os.system("rm -rf ./taosdumptest/tmp")
|
||||
os.makedirs("./taosdumptest/tmp")
|
||||
print("directory exists")
|
||||
os.system("rm -rf ./taosdumptest/tmp/*")
|
||||
|
||||
tdSql.prepare()
|
||||
|
||||
|
@ -76,17 +87,19 @@ class TDTestCase:
|
|||
tdLog.info("taosdump found in %s" % binPath)
|
||||
|
||||
os.system("rm ./taosdumptest/tmp/*.sql")
|
||||
os.system("rm ./taosdumptest/tmp/*.avro*")
|
||||
os.system("rm -rf ./taosdumptest/taosdump.*")
|
||||
os.system(
|
||||
"%s --databases db -o ./taosdumptest/tmp -B 32766 -L 1048576" %
|
||||
"%s --databases db -o ./taosdumptest/tmp " %
|
||||
binPath)
|
||||
|
||||
tdSql.execute("drop database db")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.query("show databases")
|
||||
tdSql.checkRows(2)
|
||||
|
||||
os.system("%s -i ./taosdumptest/tmp" % binPath)
|
||||
os.system("%s -i ./taosdumptest/tmp -y" % binPath)
|
||||
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.query("show databases")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(2, 0, 'db')
|
||||
|
||||
|
@ -105,17 +118,17 @@ class TDTestCase:
|
|||
"create table stb(ts timestamp, c1 binary(16374), c2 binary(16374), c3 binary(16374)) tags(t1 nchar(256))")
|
||||
tdSql.execute(
|
||||
"insert into t1 using stb tags('t1') values(now, '%s', '%s', '%s')" %
|
||||
("16374",
|
||||
"16374",
|
||||
"16374"))
|
||||
(self.generateString(16374),
|
||||
self.generateString(16374),
|
||||
self.generateString(16374)))
|
||||
|
||||
# sys.exit(0)
|
||||
os.system("rm ./taosdumptest/tmp/*.sql")
|
||||
os.system("rm ./taosdumptest/tmp/*.avro*")
|
||||
os.system("rm -rf ./taosdumptest/tmp/taosdump.*")
|
||||
os.system("%s -D test -o ./taosdumptest/tmp -y" % binPath)
|
||||
|
||||
tdSql.execute("drop database test")
|
||||
tdSql.query("select * from information_schema.ins_databases")
|
||||
tdSql.query("show databases")
|
||||
tdSql.checkRows(3)
|
||||
|
||||
os.system("%s -i ./taosdumptest/tmp -y" % binPath)
|
||||
|
|
|
@ -199,22 +199,22 @@ class TDCom:
|
|||
res = requests.post(url, sql.encode("utf-8"), headers = self.preDefine()[0])
|
||||
return res
|
||||
|
||||
def cleanTb(self, type="taosc"):
|
||||
def cleanTb(self, type="taosc", dbname="db"):
|
||||
'''
|
||||
type is taosc or restful
|
||||
'''
|
||||
query_sql = "show stables"
|
||||
query_sql = f"show {dbname}.stables"
|
||||
res_row_list = tdSql.query(query_sql, True)
|
||||
stb_list = map(lambda x: x[0], res_row_list)
|
||||
for stb in stb_list:
|
||||
if type == "taosc":
|
||||
tdSql.execute(f'drop table if exists `{stb}`')
|
||||
tdSql.execute(f'drop table if exists {dbname}.`{stb}`')
|
||||
if not stb[0].isdigit():
|
||||
tdSql.execute(f'drop table if exists {stb}')
|
||||
tdSql.execute(f'drop table if exists {dbname}.{stb}')
|
||||
elif type == "restful":
|
||||
self.restApiPost(f"drop table if exists `{stb}`")
|
||||
self.restApiPost(f"drop table if exists {dbname}.`{stb}`")
|
||||
if not stb[0].isdigit():
|
||||
self.restApiPost(f"drop table if exists {stb}")
|
||||
self.restApiPost(f"drop table if exists {dbname}.{stb}")
|
||||
|
||||
def dateToTs(self, datetime_input):
|
||||
return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f")))
|
||||
|
|
|
@ -36,9 +36,9 @@ class TDSimClient:
|
|||
"rpcDebugFlag": "143",
|
||||
"tmrDebugFlag": "131",
|
||||
"cDebugFlag": "143",
|
||||
"udebugFlag": "143",
|
||||
"jnidebugFlag": "143",
|
||||
"qdebugFlag": "143",
|
||||
"uDebugFlag": "143",
|
||||
"jniDebugFlag": "143",
|
||||
"qDebugFlag": "143",
|
||||
"supportVnodes": "1024",
|
||||
"telemetryReporting": "0",
|
||||
}
|
||||
|
@ -134,7 +134,6 @@ class TDDnode:
|
|||
"uDebugFlag": "131",
|
||||
"sDebugFlag": "143",
|
||||
"wDebugFlag": "143",
|
||||
"qdebugFlag": "143",
|
||||
"numOfLogLines": "100000000",
|
||||
"statusInterval": "1",
|
||||
"supportVnodes": "1024",
|
||||
|
@ -484,7 +483,7 @@ class TDDnode:
|
|||
psCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % toBeKilled
|
||||
processID = subprocess.check_output(
|
||||
psCmd, shell=True).decode("utf-8")
|
||||
|
||||
|
||||
onlyKillOnceWindows = 0
|
||||
while(processID):
|
||||
if not platform.system().lower() == 'windows' or (onlyKillOnceWindows == 0 and platform.system().lower() == 'windows'):
|
||||
|
|
|
@ -102,7 +102,7 @@ class TDSql:
|
|||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
args = (caller.filename, caller.lineno, sql, repr(e))
|
||||
tdLog.notice("%s(%d) failed: sql:%s, %s" % args)
|
||||
raise Exception(repr(e))
|
||||
raise Exception(repr(e))
|
||||
i+=1
|
||||
time.sleep(1)
|
||||
pass
|
||||
|
@ -225,25 +225,21 @@ class TDSql:
|
|||
# suppose user want to check nanosecond timestamp if a longer data passed
|
||||
if (len(data) >= 28):
|
||||
if pd.to_datetime(self.queryResult[row][col]) == pd.to_datetime(data):
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%s" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}")
|
||||
else:
|
||||
if self.queryResult[row][col] == _parse_datetime(data):
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}")
|
||||
return
|
||||
|
||||
if str(self.queryResult[row][col]) == str(data):
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}")
|
||||
return
|
||||
|
||||
elif isinstance(data, float):
|
||||
if abs(data) >= 1 and abs((self.queryResult[row][col] - data) / data) <= 0.000001:
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}")
|
||||
elif abs(data) < 1 and abs(self.queryResult[row][col] - data) <= 0.000001:
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}")
|
||||
else:
|
||||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data)
|
||||
|
@ -254,21 +250,7 @@ class TDSql:
|
|||
args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data)
|
||||
tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args)
|
||||
|
||||
if data is None:
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
elif isinstance(data, str):
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
elif isinstance(data, datetime.date):
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
elif isinstance(data, float):
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
else:
|
||||
tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%d" %
|
||||
(self.sql, row, col, self.queryResult[row][col], data))
|
||||
tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}")
|
||||
|
||||
def getData(self, row, col):
|
||||
self.checkRowCol(row, col)
|
||||
|
@ -307,7 +289,7 @@ class TDSql:
|
|||
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||
args = (caller.filename, caller.lineno, sql, repr(e))
|
||||
tdLog.notice("%s(%d) failed: sql:%s, %s" % args)
|
||||
raise Exception(repr(e))
|
||||
raise Exception(repr(e))
|
||||
i+=1
|
||||
time.sleep(1)
|
||||
pass
|
||||
|
@ -329,7 +311,7 @@ class TDSql:
|
|||
tdLog.exit("%s(%d) failed: sql:%s, col_name_list:%s != expect_col_name_list:%s" % args)
|
||||
|
||||
def __check_equal(self, elm, expect_elm):
|
||||
if not type(elm) in(list, tuple) and elm == expect_elm:
|
||||
if elm == expect_elm:
|
||||
return True
|
||||
if type(elm) in(list, tuple) and type(expect_elm) in(list, tuple):
|
||||
if len(elm) != len(expect_elm):
|
||||
|
|
|
@ -95,7 +95,7 @@ sql_error alter table db.stb add tag t1 int
|
|||
sql_error alter table db.stb add tag t2 int
|
||||
sql_error alter table db.stb add tag t3 int
|
||||
sql alter table db.stb add tag t4 bigint
|
||||
sql alter table db.stb add tag c1 int
|
||||
sql alter table db.stb add tag c1 int
|
||||
sql alter table db.stb add tag t5 binary(12)
|
||||
|
||||
sql select * from information_schema.ins_stables where db_name = 'db'
|
||||
|
|
|
@ -5,8 +5,8 @@ print ========= start dnode1 as master
|
|||
system sh/exec.sh -n dnode1 -s start
|
||||
sql connect
|
||||
|
||||
print ======== step1
|
||||
sql create database d1 replica 1 duration 7 keep 50
|
||||
print ======== step1
|
||||
sql create database d1 replica 1 duration 7 keep 50
|
||||
sql use d1
|
||||
sql create table tb (ts timestamp, a int)
|
||||
sql insert into tb values(now-28d, -28)
|
||||
|
@ -83,7 +83,7 @@ if $data00 != 3 then
|
|||
endi
|
||||
|
||||
print ======== step8
|
||||
# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float, g double, h binary(10) )
|
||||
# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float, g double, h binary(10) )
|
||||
sql alter table tb add column h binary(10)
|
||||
sql insert into tb values(now-7d, -7, 18, 0, 0, 0, 0, 0, '0')
|
||||
sql insert into tb values(now-6d, -6, 19, 1, 1, 1, 1, 1, '1')
|
||||
|
@ -260,4 +260,4 @@ if $data00 != 31 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -5,7 +5,7 @@ print ========= start dnode1 as master
|
|||
system sh/exec.sh -n dnode1 -s start
|
||||
sql connect
|
||||
|
||||
print ======== step1
|
||||
print ======== step1
|
||||
sql create database d1 replica 1 duration 7 keep 50
|
||||
sql use d1
|
||||
sql create table tb (ts timestamp, a int)
|
||||
|
@ -42,4 +42,4 @@ if $data00 != 6 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
|||
system sh/exec.sh -n dnode1 -s start
|
||||
sql connect
|
||||
|
||||
print ======== step1
|
||||
print ======== step1
|
||||
sql create database d3
|
||||
sql use d3
|
||||
sql create table tb (ts timestamp, a int)
|
||||
|
@ -1137,4 +1137,4 @@ if $data79 != null then
|
|||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
|||
system sh/exec.sh -n dnode1 -s start
|
||||
sql connect
|
||||
|
||||
print ======== step1
|
||||
print ======== step1
|
||||
sql create database d4
|
||||
sql use d4
|
||||
sql create table tb (ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float, g double, h binary(10))
|
||||
|
@ -662,4 +662,4 @@ if $data62 != null then
|
|||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
|||
system sh/exec.sh -n dnode1 -s start
|
||||
sql connect
|
||||
|
||||
print ======== step1
|
||||
print ======== step1
|
||||
sql create database d2
|
||||
sql use d2
|
||||
sql create table mt (ts timestamp, a int) TAGS (t int)
|
||||
|
@ -757,8 +757,8 @@ endi
|
|||
print ======= over
|
||||
sql drop database d2
|
||||
sql select * from information_schema.ins_databases
|
||||
if $rows != 2 then
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -116,7 +116,7 @@ if $data[0][1] != 1 then
|
|||
endi
|
||||
if $data[0][2] != 2 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data[0][3] != NULL then
|
||||
return -1
|
||||
endi
|
||||
|
@ -153,7 +153,7 @@ if $data[0][1] != 1 then
|
|||
endi
|
||||
if $data[0][2] != 2 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data[0][3] != NULL then
|
||||
return -1
|
||||
endi
|
||||
|
@ -299,4 +299,4 @@ if $rows != 10 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -31,7 +31,7 @@ if $data[0][1] != 1 then
|
|||
endi
|
||||
if $data[0][2] != 1234 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data[0][3] != 101 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -92,7 +92,7 @@ if $data[0][1] != 1 then
|
|||
endi
|
||||
if $data[0][2] != 1234 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data[0][3] != 101 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -106,4 +106,4 @@ if $data[1][3] != 101 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -188,4 +188,4 @@ if $rows != 2 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -123,4 +123,4 @@ if $rows != 2 then
|
|||
endi
|
||||
|
||||
print =============== step6
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -139,7 +139,7 @@ if $data[0][1] != 1 then
|
|||
endi
|
||||
if $data[0][2] != 2 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data[0][3] != 101 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -170,7 +170,7 @@ if $data[0][1] != 1 then
|
|||
endi
|
||||
if $data[0][2] != 2 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data[0][3] != 101 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -190,4 +190,4 @@ if $rows != 7 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -165,7 +165,7 @@ if $data[0][1] != 1 then
|
|||
endi
|
||||
if $data[0][2] != 2 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data[0][3] != 101 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -196,7 +196,7 @@ if $data[0][1] != 1 then
|
|||
endi
|
||||
if $data[0][2] != 2 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data[0][3] != 201 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -229,7 +229,7 @@ if $data[0][1] != 1 then
|
|||
endi
|
||||
if $data[0][2] != 2 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data[0][3] != 201 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -261,7 +261,7 @@ if $data[0][1] != 1 then
|
|||
endi
|
||||
if $data[0][2] != 2 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data[0][3] != 301 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -323,7 +323,7 @@ if $data[0][1] != 1 then
|
|||
endi
|
||||
if $data[0][2] != 2 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data[0][3] != 302 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -334,4 +334,4 @@ if $data[0][5] != 304 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -27,47 +27,47 @@ sql create table db.ctb6 using db.stb tags(6, "102")
|
|||
sql insert into db.ctb6 values(now, 6, "2")
|
||||
|
||||
sql select * from db.stb where t1 = 1
|
||||
if $rows != 1 then
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select * from db.stb where t1 < 1
|
||||
if $rows != 0 then
|
||||
sql select * from db.stb where t1 < 1
|
||||
if $rows != 0 then
|
||||
return -=1
|
||||
endi
|
||||
|
||||
sql select * from db.stb where t1 < 2
|
||||
if $rows != 1 then
|
||||
sql select * from db.stb where t1 < 2
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select * from db.stb where t1 <= 2
|
||||
if $rows != 2 then
|
||||
sql select * from db.stb where t1 <= 2
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select * from db.stb where t1 >= 1
|
||||
if $rows != 6 then
|
||||
sql select * from db.stb where t1 >= 1
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select * from db.stb where t1 > 1
|
||||
if $rows != 5 then
|
||||
sql select * from db.stb where t1 > 1
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select * from db.stb where t1 between 1 and 1
|
||||
if $rows != 1 then
|
||||
sql select * from db.stb where t1 between 1 and 1
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select * from db.stb where t1 between 1 and 6
|
||||
if $rows != 6 then
|
||||
sql select * from db.stb where t1 between 1 and 6
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select * from db.stb where t1 between 1 and 7
|
||||
if $rows != 6 then
|
||||
sql select * from db.stb where t1 between 1 and 7
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -88,25 +88,25 @@ sql insert into db.ctbBin2 values(now, 3, "2")
|
|||
sql create table db.ctbBin3 using db.stbBin tags("d")
|
||||
sql insert into db.ctbBin3 values(now, 4, "2")
|
||||
|
||||
sql select * from db.stbBin where t1 = "a"
|
||||
if $rows != 1 then
|
||||
sql select * from db.stbBin where t1 = "a"
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
sql select * from db.stbBin where t1 < "a"
|
||||
if $rows != 0 then
|
||||
sql select * from db.stbBin where t1 < "a"
|
||||
if $rows != 0 then
|
||||
return -=1
|
||||
endi
|
||||
|
||||
sql select * from db.stbBin where t1 < "b"
|
||||
if $rows != 1 then
|
||||
sql select * from db.stbBin where t1 < "b"
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
sql select * from db.stbBin where t1 between "a" and "e"
|
||||
if $rows != 4 then
|
||||
sql select * from db.stbBin where t1 between "a" and "e"
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -127,25 +127,25 @@ sql insert into db.ctbNc2 values(now, 3, "2")
|
|||
sql create table db.ctbNc3 using db.stbNc tags("d")
|
||||
sql insert into db.ctbNc3 values(now, 4, "2")
|
||||
|
||||
sql select * from db.stbNc where t1 = "a"
|
||||
if $rows != 1 then
|
||||
sql select * from db.stbNc where t1 = "a"
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
sql select * from db.stbNc where t1 < "a"
|
||||
if $rows != 0 then
|
||||
sql select * from db.stbNc where t1 < "a"
|
||||
if $rows != 0 then
|
||||
return -=1
|
||||
endi
|
||||
|
||||
sql select * from db.stbNc where t1 < "b"
|
||||
if $rows != 1 then
|
||||
sql select * from db.stbNc where t1 < "b"
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
||||
sql select * from db.stbNc where t1 between "a" and "e"
|
||||
if $rows != 4 then
|
||||
sql select * from db.stbNc where t1 between "a" and "e"
|
||||
if $rows != 4 then
|
||||
return -1
|
||||
endi
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -28,7 +28,7 @@ if $data[0][1] != 1 then
|
|||
endi
|
||||
if $data[0][2] != 1234 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data[0][3] != 101 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -55,7 +55,7 @@ if $data[0][1] != 1 then
|
|||
endi
|
||||
if $data[0][2] != 1234 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data[0][3] != 101 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -120,4 +120,4 @@ if $data[4][2] != 5 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -28,7 +28,7 @@ if $data[0][1] != 1 then
|
|||
endi
|
||||
if $data[0][2] != 1234 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data[0][3] != 101 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -52,7 +52,7 @@ if $data[0][1] != 1 then
|
|||
endi
|
||||
if $data[0][2] != 1234 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
||||
if $data[0][3] != 101 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -117,4 +117,4 @@ if $data[4][2] != 4 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/deploy.sh -n dnode2 -i 2
|
||||
system sh/deploy.sh -n dnode3 -i 3
|
||||
system sh/deploy.sh -n dnode4 -i 4
|
||||
|
||||
system sh/cfg.sh -n dnode1 -c supportVnodes -v 0
|
||||
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
system sh/exec.sh -n dnode2 -s start
|
||||
system sh/exec.sh -n dnode3 -s start
|
||||
system sh/exec.sh -n dnode4 -s start
|
||||
|
||||
sql connect
|
||||
sql create dnode $hostname port 7200
|
||||
sql create dnode $hostname port 7300
|
||||
sql create dnode $hostname port 7400
|
||||
|
||||
sql create mnode on dnode 2
|
||||
sql create mnode on dnode 3
|
|
@ -163,6 +163,9 @@ sql select * from information_schema.ins_stables
|
|||
sql select * from information_schema.ins_tables
|
||||
sql select * from information_schema.ins_tags
|
||||
sql select * from information_schema.ins_users
|
||||
sql select * from information_schema.ins_topics
|
||||
sql select * from information_schema.ins_subscriptions
|
||||
sql select * from information_schema.ins_streams
|
||||
sql_error select * from information_schema.ins_grants
|
||||
sql_error select * from information_schema.ins_vgroups
|
||||
sql_error select * from information_schema.ins_configs
|
||||
|
@ -172,11 +175,8 @@ print =============== check performance_schema
|
|||
sql use performance_schema;
|
||||
sql select * from performance_schema.perf_connections
|
||||
sql select * from performance_schema.perf_queries
|
||||
sql select * from performance_schema.perf_topics
|
||||
sql select * from performance_schema.perf_consumers
|
||||
sql select * from performance_schema.perf_subscriptions
|
||||
sql select * from performance_schema.perf_trans
|
||||
sql select * from performance_schema.perf_streams
|
||||
sql select * from performance_schema.perf_apps
|
||||
|
||||
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
|
|
|
@ -31,7 +31,7 @@ if platform.system().lower() == 'windows':
|
|||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
tdSql.init(conn.cursor(), False)
|
||||
self._conn = conn
|
||||
|
||||
def createDb(self, name="test", db_update_tag=0):
|
||||
|
@ -357,7 +357,7 @@ class TDTestCase:
|
|||
"""
|
||||
normal tags and cols, one for every elm
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql()
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
||||
|
@ -365,7 +365,7 @@ class TDTestCase:
|
|||
"""
|
||||
check all normal type
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
full_type_list = ["f", "F", "false", "False", "t", "T", "true", "True"]
|
||||
for t_type in full_type_list:
|
||||
input_sql, stb_name = self.genFullTypeSql(c0=t_type, t0=t_type)
|
||||
|
@ -379,7 +379,7 @@ class TDTestCase:
|
|||
please test :
|
||||
binary_symbols = '\"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"\'\'"\"'
|
||||
'''
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
binary_symbols = '"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"'
|
||||
nchar_symbols = f'L{binary_symbols}'
|
||||
input_sql, stb_name = self.genFullTypeSql(c7=binary_symbols, c8=nchar_symbols, t7=binary_symbols, t8=nchar_symbols)
|
||||
|
@ -390,7 +390,7 @@ class TDTestCase:
|
|||
test ts list --> ["1626006833639000000", "1626006833639019us", "1626006833640ms", "1626006834s", "1626006822639022"]
|
||||
# ! us级时间戳都为0时,数据库中查询显示,但python接口拿到的结果不显示 .000000的情况请确认,目前修改时间处理代码可以通过
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
ts_list = ["1626006833639000000", "1626006833639019us", "1626006833640ms", "1626006834s", "1626006822639022", 0]
|
||||
for ts in ts_list:
|
||||
input_sql, stb_name = self.genFullTypeSql(ts=ts)
|
||||
|
@ -401,7 +401,7 @@ class TDTestCase:
|
|||
check id.index in tags
|
||||
eg: t0=**,id=**,t1=**
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(id_change_tag=True)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
||||
|
@ -410,7 +410,7 @@ class TDTestCase:
|
|||
check id param
|
||||
eg: id and ID
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(id_upper_tag=True)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, id_upper_tag=True)
|
||||
|
@ -420,7 +420,7 @@ class TDTestCase:
|
|||
"""
|
||||
id not exist
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(id_noexist_tag=True)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
query_sql = f"select tbname from {stb_name}"
|
||||
|
@ -436,10 +436,10 @@ class TDTestCase:
|
|||
max col count is ??
|
||||
"""
|
||||
for input_sql in [self.genLongSql(127, 1)[0], self.genLongSql(1, 4093)[0]]:
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
|
||||
for input_sql in [self.genLongSql(129, 1)[0], self.genLongSql(1, 4095)[0]]:
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
try:
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
|
||||
except SchemalessError as err:
|
||||
|
@ -450,7 +450,7 @@ class TDTestCase:
|
|||
test illegal id name
|
||||
mix "~!@#$¥%^&*()-+|[]、「」【】;:《》<>?"
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
rstr = list("~!@#$¥%^&*()-+|[]、「」【】;:《》<>?")
|
||||
for i in rstr:
|
||||
stb_name=f"aaa{i}bbb"
|
||||
|
@ -462,7 +462,7 @@ class TDTestCase:
|
|||
"""
|
||||
id is start with num
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = self.genFullTypeSql(tb_name=f"\"1aaabbb\"")[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
|
||||
|
@ -473,7 +473,7 @@ class TDTestCase:
|
|||
"""
|
||||
check now unsupported
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = self.genFullTypeSql(ts="now")[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
|
||||
|
@ -484,7 +484,7 @@ class TDTestCase:
|
|||
"""
|
||||
check date format ts unsupported
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = self.genFullTypeSql(ts="2021-07-21\ 19:01:46.920")[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
|
||||
|
@ -495,7 +495,7 @@ class TDTestCase:
|
|||
"""
|
||||
check ts format like 16260068336390us19
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = self.genFullTypeSql(ts="16260068336390us19")[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
|
||||
|
@ -506,7 +506,7 @@ class TDTestCase:
|
|||
"""
|
||||
check full type tag value limit
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
# i8
|
||||
for t1 in ["-128i8", "127i8"]:
|
||||
input_sql, stb_name = self.genFullTypeSql(t1=t1)
|
||||
|
@ -602,7 +602,7 @@ class TDTestCase:
|
|||
"""
|
||||
check full type col value limit
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
# i8
|
||||
for c1 in ["-128i8", "127i8"]:
|
||||
input_sql, stb_name = self.genFullTypeSql(c1=c1)
|
||||
|
@ -699,7 +699,7 @@ class TDTestCase:
|
|||
"""
|
||||
test illegal tag col value
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
# bool
|
||||
for i in ["TrUe", "tRue", "trUe", "truE", "FalsE", "fAlse", "faLse", "falSe", "falsE"]:
|
||||
input_sql1 = self.genFullTypeSql(t0=i)[0]
|
||||
|
@ -758,7 +758,7 @@ class TDTestCase:
|
|||
"""
|
||||
check duplicate Id Tag Col
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql_id = self.genFullTypeSql(id_double_tag=True)[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([input_sql_id], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
|
||||
|
@ -792,7 +792,7 @@ class TDTestCase:
|
|||
"""
|
||||
case no id when stb exist
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name="sub_table_0123456", t0="f", c0="f")
|
||||
self.resCmp(input_sql, stb_name)
|
||||
input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, id_noexist_tag=True, t0="f", c0="f")
|
||||
|
@ -805,7 +805,7 @@ class TDTestCase:
|
|||
"""
|
||||
check duplicate insert when stb exist
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql()
|
||||
self.resCmp(input_sql, stb_name)
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.LINE.value, TDSmlTimestampType.NANO_SECOND.value)
|
||||
|
@ -816,7 +816,7 @@ class TDTestCase:
|
|||
"""
|
||||
check length increase
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql()
|
||||
self.resCmp(input_sql, stb_name)
|
||||
tb_name = tdCom.getLongName(5, "letters")
|
||||
|
@ -833,7 +833,7 @@ class TDTestCase:
|
|||
* col is added without value when update==0
|
||||
* col is added with value when update==1
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
for db_update_tag in [0, 1]:
|
||||
if db_update_tag == 1 :
|
||||
|
@ -850,7 +850,7 @@ class TDTestCase:
|
|||
"""
|
||||
check column and tag count add
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, t0="f", c0="f")
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
@ -866,7 +866,7 @@ class TDTestCase:
|
|||
condition: stb not change
|
||||
insert two table, keep tag unchange, change col
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(t0="f", c0="f", id_noexist_tag=True)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
tb_name1 = self.getNoIdTbName(stb_name)
|
||||
|
@ -888,7 +888,7 @@ class TDTestCase:
|
|||
"""
|
||||
every binary and nchar must be length+2
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
stb_name = tdCom.getLongName(7, "letters")
|
||||
tb_name = f'{stb_name}_1'
|
||||
input_sql = f'{stb_name},id="{tb_name}",t0=t c0=f 1626006833639000000'
|
||||
|
@ -928,7 +928,7 @@ class TDTestCase:
|
|||
"""
|
||||
check nchar length limit
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
stb_name = tdCom.getLongName(7, "letters")
|
||||
tb_name = f'{stb_name}_1'
|
||||
input_sql = f'{stb_name},id="{tb_name}",t0=t c0=f 1626006833639000000'
|
||||
|
@ -963,7 +963,7 @@ class TDTestCase:
|
|||
"""
|
||||
test batch insert
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
stb_name = tdCom.getLongName(8, "letters")
|
||||
# tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)')
|
||||
lines = ["st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
|
||||
|
@ -982,7 +982,7 @@ class TDTestCase:
|
|||
"""
|
||||
test multi insert
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
sql_list = []
|
||||
stb_name = tdCom.getLongName(8, "letters")
|
||||
# tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)')
|
||||
|
@ -996,7 +996,7 @@ class TDTestCase:
|
|||
"""
|
||||
test batch error insert
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
stb_name = tdCom.getLongName(8, "letters")
|
||||
lines = ["st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
|
||||
f"{stb_name},t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532ns"]
|
||||
|
@ -1068,7 +1068,7 @@ class TDTestCase:
|
|||
"""
|
||||
thread input different stb
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = self.genSqlList()[0]
|
||||
self.multiThreadRun(self.genMultiThreadSeq(input_sql))
|
||||
tdSql.query(f"show tables;")
|
||||
|
@ -1078,7 +1078,7 @@ class TDTestCase:
|
|||
"""
|
||||
thread input same stb tb, different data, result keep first data
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
@ -1095,7 +1095,7 @@ class TDTestCase:
|
|||
"""
|
||||
thread input same stb tb, different data, add columes and tags, result keep first data
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
@ -1112,7 +1112,7 @@ class TDTestCase:
|
|||
"""
|
||||
thread input same stb tb, different data, minus columes and tags, result keep first data
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
@ -1129,7 +1129,7 @@ class TDTestCase:
|
|||
"""
|
||||
thread input same stb, different tb, different data
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql()
|
||||
self.resCmp(input_sql, stb_name)
|
||||
s_stb_d_tb_list = self.genSqlList(stb_name=stb_name)[4]
|
||||
|
@ -1144,7 +1144,7 @@ class TDTestCase:
|
|||
"""
|
||||
thread input same stb, different tb, different data, add col, mul tag
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql()
|
||||
self.resCmp(input_sql, stb_name)
|
||||
s_stb_d_tb_a_col_m_tag_list = self.genSqlList(stb_name=stb_name)[5]
|
||||
|
@ -1159,7 +1159,7 @@ class TDTestCase:
|
|||
"""
|
||||
thread input same stb, different tb, different data, add tag, mul col
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql()
|
||||
self.resCmp(input_sql, stb_name)
|
||||
s_stb_d_tb_a_tag_m_col_list = self.genSqlList(stb_name=stb_name)[6]
|
||||
|
@ -1171,7 +1171,7 @@ class TDTestCase:
|
|||
"""
|
||||
thread input same stb tb, different ts
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
@ -1186,7 +1186,7 @@ class TDTestCase:
|
|||
"""
|
||||
thread input same stb tb, different ts, add col, mul tag
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
@ -1205,7 +1205,7 @@ class TDTestCase:
|
|||
"""
|
||||
thread input same stb tb, different ts, add tag, mul col
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
@ -1226,7 +1226,7 @@ class TDTestCase:
|
|||
"""
|
||||
thread input same stb, different tb, data, ts
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql()
|
||||
self.resCmp(input_sql, stb_name)
|
||||
s_stb_d_tb_d_ts_list = self.genSqlList(stb_name=stb_name)[10]
|
||||
|
@ -1241,7 +1241,7 @@ class TDTestCase:
|
|||
"""
|
||||
thread input same stb, different tb, data, ts, add col, mul tag
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql()
|
||||
self.resCmp(input_sql, stb_name)
|
||||
s_stb_d_tb_d_ts_a_col_m_tag_list = self.genSqlList(stb_name=stb_name)[11]
|
||||
|
|
|
@ -459,7 +459,7 @@ class TDTestCase:
|
|||
normal tags and cols, one for every elm
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json, stb_name = self.genFullTypeJson(value_type=value_type)
|
||||
self.resCmp(input_json, stb_name)
|
||||
|
||||
|
@ -468,7 +468,7 @@ class TDTestCase:
|
|||
check all normal type
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
full_type_list = ["f", "F", "false", "False", "t", "T", "true", "True"]
|
||||
for t_type in full_type_list:
|
||||
input_json_list = [self.genFullTypeJson(tag_value=self.genTagValue(t0_value=t_type))[0],
|
||||
|
@ -489,7 +489,7 @@ class TDTestCase:
|
|||
binary_symbols = '\"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"\'\'"\"'
|
||||
'''
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
binary_symbols = '"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"'
|
||||
nchar_symbols = binary_symbols
|
||||
input_sql1, stb_name1 = self.genFullTypeJson(col_value=self.genTsColValue(value=binary_symbols, t_type="binary", value_type=value_type),
|
||||
|
@ -505,7 +505,7 @@ class TDTestCase:
|
|||
# ! us级时间戳都为0时,数据库中查询显示,但python接口拿到的结果不显示 .000000的情况请确认,目前修改时间处理代码可以通过
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
ts_list = ["1626006833639000000ns", "1626006833639019us", "1626006833640ms", "1626006834s", "1626006834", 0]
|
||||
for ts in ts_list:
|
||||
if "s" in str(ts):
|
||||
|
@ -571,7 +571,7 @@ class TDTestCase:
|
|||
eg: t0=**,id=**,t1=**
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json, stb_name = self.genFullTypeJson(id_change_tag=True, value_type=value_type)
|
||||
self.resCmp(input_json, stb_name)
|
||||
|
||||
|
@ -581,7 +581,7 @@ class TDTestCase:
|
|||
eg: id and ID
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json, stb_name = self.genFullTypeJson(id_upper_tag=True, value_type=value_type)
|
||||
self.resCmp(input_json, stb_name)
|
||||
input_json, stb_name = self.genFullTypeJson(id_mixul_tag=True, value_type=value_type)
|
||||
|
@ -594,7 +594,7 @@ class TDTestCase:
|
|||
id not exist
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json, stb_name = self.genFullTypeJson(id_noexist_tag=True, value_type=value_type)
|
||||
self.resCmp(input_json, stb_name)
|
||||
query_sql = f"select tbname from {stb_name}"
|
||||
|
@ -610,10 +610,10 @@ class TDTestCase:
|
|||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
for input_json in [self.genLongJson(128, value_type)[0]]:
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
for input_json in [self.genLongJson(129, value_type)[0]]:
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
try:
|
||||
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
except SchemalessError as err:
|
||||
|
@ -625,7 +625,7 @@ class TDTestCase:
|
|||
mix "`~!@#$¥%^&*()-+={}|[]、「」【】\:;《》<>?"
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
rstr = list("`~!@#$¥%^&*()-+={}|[]、「」【】\:;《》<>?")
|
||||
for i in rstr:
|
||||
input_json = self.genFullTypeJson(tb_name=f'aa{i}bb', value_type=value_type)[0]
|
||||
|
@ -639,7 +639,7 @@ class TDTestCase:
|
|||
id is start with num
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json = self.genFullTypeJson(tb_name="1aaabbb", value_type=value_type)[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
|
@ -651,7 +651,7 @@ class TDTestCase:
|
|||
check now unsupported
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json = self.genFullTypeJson(ts_value=self.genTsColValue(value="now", t_type="ns", value_type=value_type))[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
|
@ -663,7 +663,7 @@ class TDTestCase:
|
|||
check date format ts unsupported
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json = self.genFullTypeJson(ts_value=self.genTsColValue(value="2021-07-21\ 19:01:46.920", t_type="ns", value_type=value_type))[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
|
@ -675,7 +675,7 @@ class TDTestCase:
|
|||
check ts format like 16260068336390us19
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json = self.genFullTypeJson(ts_value=self.genTsColValue(value="16260068336390us19", t_type="us", value_type=value_type))[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
|
@ -690,7 +690,7 @@ class TDTestCase:
|
|||
length of stb_name tb_name <= 192
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tdSql.execute('reset query cache')
|
||||
stb_name_192 = tdCom.getLongName(len=192, mode="letters")
|
||||
tb_name_192 = tdCom.getLongName(len=192, mode="letters")
|
||||
|
@ -715,7 +715,7 @@ class TDTestCase:
|
|||
check tag name limit <= 62
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tag_name = tdCom.getLongName(61, "letters")
|
||||
tag_name = f't{tag_name}'
|
||||
stb_name = tdCom.getLongName(7, "letters")
|
||||
|
@ -733,7 +733,7 @@ class TDTestCase:
|
|||
check full type tag value limit
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
# i8
|
||||
for t1 in [-127, 127]:
|
||||
input_json, stb_name = self.genFullTypeJson(tag_value=self.genTagValue(t1_value=t1, value_type=value_type))
|
||||
|
@ -854,12 +854,12 @@ class TDTestCase:
|
|||
check full type col value limit
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
# i8
|
||||
for value in [-128, 127]:
|
||||
input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="tinyint", value_type=value_type))
|
||||
self.resCmp(input_json, stb_name)
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in [-129, 128]:
|
||||
input_json = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="tinyint"))[0]
|
||||
try:
|
||||
|
@ -868,11 +868,11 @@ class TDTestCase:
|
|||
except SchemalessError as err:
|
||||
tdSql.checkNotEqual(err.errno, 0)
|
||||
# i16
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in [-32768]:
|
||||
input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="smallint", value_type=value_type))
|
||||
self.resCmp(input_json, stb_name)
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in [-32769, 32768]:
|
||||
input_json = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="smallint"))[0]
|
||||
try:
|
||||
|
@ -882,11 +882,11 @@ class TDTestCase:
|
|||
tdSql.checkNotEqual(err.errno, 0)
|
||||
|
||||
# i32
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in [-2147483648]:
|
||||
input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="int", value_type=value_type))
|
||||
self.resCmp(input_json, stb_name)
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in [-2147483649, 2147483648]:
|
||||
input_json = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="int"))[0]
|
||||
try:
|
||||
|
@ -896,12 +896,12 @@ class TDTestCase:
|
|||
tdSql.checkNotEqual(err.errno, 0)
|
||||
|
||||
# i64
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in [-9223372036854775808]:
|
||||
input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="bigint", value_type=value_type))
|
||||
self.resCmp(input_json, stb_name)
|
||||
# ! bug
|
||||
# tdCom.cleanTb()
|
||||
# tdCom.cleanTb(dbname="test")
|
||||
# for value in [-9223372036854775809, 9223372036854775808]:
|
||||
# print(value)
|
||||
# input_json = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="bigint"))[0]
|
||||
|
@ -913,12 +913,12 @@ class TDTestCase:
|
|||
# tdSql.checkNotEqual(err.errno, 0)
|
||||
|
||||
# f32
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in [-3.4028234663852885981170418348451692544*(10**38), 3.4028234663852885981170418348451692544*(10**38)]:
|
||||
input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="float", value_type=value_type))
|
||||
self.resCmp(input_json, stb_name)
|
||||
# * limit set to 4028234664*(10**38)
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in [-3.4028234664*(10**38), 3.4028234664*(10**38)]:
|
||||
input_json = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="float"))[0]
|
||||
try:
|
||||
|
@ -928,12 +928,12 @@ class TDTestCase:
|
|||
tdSql.checkNotEqual(err.errno, 0)
|
||||
|
||||
# f64
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in [-1.79769313486231570814527423731704356798070567525844996598917476803157260780*(10**308), -1.79769313486231570814527423731704356798070567525844996598917476803157260780*(10**308)]:
|
||||
input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="double", value_type=value_type))
|
||||
self.resCmp(input_json, stb_name)
|
||||
# * limit set to 1.797693134862316*(10**308)
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in [-1.797693134862316*(10**308), -1.797693134862316*(10**308)]:
|
||||
input_json = self.genFullTypeJson(col_value=self.genTsColValue(value=value, t_type="double", value_type=value_type))[0]
|
||||
try:
|
||||
|
@ -944,12 +944,12 @@ class TDTestCase:
|
|||
|
||||
# if value_type == "obj":
|
||||
# # binary
|
||||
# tdCom.cleanTb()
|
||||
# tdCom.cleanTb(dbname="test")
|
||||
# stb_name = tdCom.getLongName(7, "letters")
|
||||
# input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': tdCom.getLongName(16374, "letters"), 'type': 'binary'}, "tags": {"t0": {'value': True, 'type': 'bool'}}}
|
||||
# self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
|
||||
# tdCom.cleanTb()
|
||||
# tdCom.cleanTb(dbname="test")
|
||||
# input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': tdCom.getLongName(16375, "letters"), 'type': 'binary'}, "tags": {"t0": {'value': True, 'type': 'bool'}}}
|
||||
# try:
|
||||
# self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
|
@ -959,12 +959,12 @@ class TDTestCase:
|
|||
|
||||
# # nchar
|
||||
# # * legal nchar could not be larger than 16374/4
|
||||
# tdCom.cleanTb()
|
||||
# tdCom.cleanTb(dbname="test")
|
||||
# stb_name = tdCom.getLongName(7, "letters")
|
||||
# input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': tdCom.getLongName(4093, "letters"), 'type': 'nchar'}, "tags": {"t0": {'value': True, 'type': 'bool'}}}
|
||||
# self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
|
||||
# tdCom.cleanTb()
|
||||
# tdCom.cleanTb(dbname="test")
|
||||
# input_json = {"metric": stb_name, "timestamp": {'value': 1626006833639000000, 'type': 'ns'}, "value": {'value': tdCom.getLongName(4094, "letters"), 'type': 'nchar'}, "tags": {"t0": {'value': True, 'type': 'bool'}}}
|
||||
# try:
|
||||
# self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
|
@ -973,14 +973,14 @@ class TDTestCase:
|
|||
# tdSql.checkNotEqual(err.errno, 0)
|
||||
# elif value_type == "default":
|
||||
# # binary
|
||||
# tdCom.cleanTb()
|
||||
# tdCom.cleanTb(dbname="test")
|
||||
# stb_name = tdCom.getLongName(7, "letters")
|
||||
# if tdSql.getVariable("defaultJSONStrType")[0].lower() == "binary":
|
||||
# input_json = {"metric": stb_name, "timestamp": 1626006834, "value": tdCom.getLongName(16374, "letters"), "tags": {"t0": {'value': True, 'type': 'bool'}}}
|
||||
# elif tdSql.getVariable("defaultJSONStrType")[0].lower() == "nchar":
|
||||
# input_json = {"metric": stb_name, "timestamp": 1626006834, "value": tdCom.getLongName(4093, "letters"), "tags": {"t0": {'value': True, 'type': 'bool'}}}
|
||||
# self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
# tdCom.cleanTb()
|
||||
# tdCom.cleanTb(dbname="test")
|
||||
# if tdSql.getVariable("defaultJSONStrType")[0].lower() == "binary":
|
||||
# input_json = {"metric": stb_name, "timestamp": 1626006834, "value": tdCom.getLongName(16375, "letters"), "tags": {"t0": {'value': True, 'type': 'bool'}}}
|
||||
# elif tdSql.getVariable("defaultJSONStrType")[0].lower() == "nchar":
|
||||
|
@ -997,7 +997,7 @@ class TDTestCase:
|
|||
test illegal tag col value
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
# bool
|
||||
for i in ["TrUe", "tRue", "trUe", "truE", "FalsE", "fAlse", "faLse", "falSe", "falsE"]:
|
||||
try:
|
||||
|
@ -1046,7 +1046,7 @@ class TDTestCase:
|
|||
check duplicate Id Tag Col
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json = self.genFullTypeJson(id_double_tag=True, value_type=value_type)[0]
|
||||
print(input_json)
|
||||
try:
|
||||
|
@ -1068,7 +1068,7 @@ class TDTestCase:
|
|||
case no id when stb exist
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json, stb_name = self.genFullTypeJson(tb_name="sub_table_0123456", col_value=self.genTsColValue(value=True, t_type="bool", value_type=value_type), tag_value=self.genTagValue(t0_value=True, value_type=value_type))
|
||||
self.resCmp(input_json, stb_name)
|
||||
input_json, stb_name = self.genFullTypeJson(stb_name=stb_name, id_noexist_tag=True, col_value=self.genTsColValue(value=True, t_type="bool", value_type=value_type), tag_value=self.genTagValue(t0_value=True, value_type=value_type))
|
||||
|
@ -1081,7 +1081,7 @@ class TDTestCase:
|
|||
check duplicate insert when stb exist
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json, stb_name = self.genFullTypeJson(value_type=value_type)
|
||||
self.resCmp(input_json, stb_name)
|
||||
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
|
@ -1091,7 +1091,7 @@ class TDTestCase:
|
|||
"""
|
||||
check length increase
|
||||
"""
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json, stb_name = self.genFullTypeJson(value_type=value_type)
|
||||
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
self.resCmp(input_json, stb_name)
|
||||
|
@ -1105,7 +1105,7 @@ class TDTestCase:
|
|||
check length increase
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
stb_name = "test_crash"
|
||||
input_json = self.genFullTypeJson(stb_name=stb_name)[0]
|
||||
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
|
@ -1128,7 +1128,7 @@ class TDTestCase:
|
|||
* col is added with value when update==1
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
for db_update_tag in [0, 1]:
|
||||
if db_update_tag == 1 :
|
||||
|
@ -1154,7 +1154,7 @@ class TDTestCase:
|
|||
check tag count add
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value=True, t_type="bool", value_type=value_type), tag_value=self.genTagValue(t0_value=True, value_type=value_type))
|
||||
self.resCmp(input_json, stb_name)
|
||||
|
@ -1171,7 +1171,7 @@ class TDTestCase:
|
|||
insert two table, keep tag unchange, change col
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value=True, t_type="bool", value_type=value_type), tag_value=self.genTagValue(t0_value=True, value_type=value_type), id_noexist_tag=True)
|
||||
self.resCmp(input_json, stb_name)
|
||||
tb_name1 = self.getNoIdTbName(stb_name)
|
||||
|
@ -1194,7 +1194,7 @@ class TDTestCase:
|
|||
every binary and nchar must be length+2
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
stb_name = tdCom.getLongName(7, "letters")
|
||||
tb_name = f'{stb_name}_1'
|
||||
tag_value = {"t0": {"value": True, "type": "bool"}}
|
||||
|
@ -1240,7 +1240,7 @@ class TDTestCase:
|
|||
check nchar length limit
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
stb_name = tdCom.getLongName(7, "letters")
|
||||
tb_name = f'{stb_name}_1'
|
||||
tag_value = {"t0": True}
|
||||
|
@ -1284,7 +1284,7 @@ class TDTestCase:
|
|||
test batch insert
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
stb_name = "stb_name"
|
||||
tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)')
|
||||
input_json = [{"metric": "st123456", "timestamp": {"value": 1626006833639000000, "type": "ns"}, "value": {"value": 1, "type": "bigint"}, "tags": {"t1": {"value": 3, "type": "bigint"}, "t2": {"value": 4, "type": "double"}, "t3": {"value": "t3", "type": "binary"}}},
|
||||
|
@ -1319,7 +1319,7 @@ class TDTestCase:
|
|||
test multi insert
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
sql_list = list()
|
||||
stb_name = tdCom.getLongName(8, "letters")
|
||||
tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)')
|
||||
|
@ -1335,7 +1335,7 @@ class TDTestCase:
|
|||
test batch error insert
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json = [{"metric": "st123456", "timestamp": {"value": 1626006833639000000, "type": "ns"}, "value": {"value": "tt", "type": "bool"}, "tags": {"t1": {"value": 3, "type": "bigint"}, "t2": {"value": 4, "type": "double"}, "t3": {"value": "t3", "type": "binary"}}},
|
||||
{"metric": "st123456", "timestamp": {"value": 1626006933641000000, "type": "ns"}, "value": {"value": 9, "type": "bigint"}, "tags": {"t1": {"value": 4, "type": "bigint"}, "t3": {"value": "t4", "type": "binary"}, "t2": {"value": 5, "type": "double"}, "t4": {"value": 5, "type": "double"}}}]
|
||||
try:
|
||||
|
@ -1349,7 +1349,7 @@ class TDTestCase:
|
|||
test multi cols insert
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json = self.genFullTypeJson(c_multi_tag=True, value_type=value_type)[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
|
@ -1362,7 +1362,7 @@ class TDTestCase:
|
|||
test blank col insert
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json = self.genFullTypeJson(c_blank_tag=True, value_type=value_type)[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
|
@ -1375,7 +1375,7 @@ class TDTestCase:
|
|||
test blank tag insert
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json = self.genFullTypeJson(t_blank_tag=True, value_type=value_type)[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
|
@ -1388,7 +1388,7 @@ class TDTestCase:
|
|||
check nchar ---> chinese
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json, stb_name = self.genFullTypeJson(chinese_tag=True)
|
||||
self.resCmp(input_json, stb_name)
|
||||
|
||||
|
@ -1397,7 +1397,7 @@ class TDTestCase:
|
|||
multi_field
|
||||
'''
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json = self.genFullTypeJson(multi_field_tag=True, value_type=value_type)[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
|
@ -1407,7 +1407,7 @@ class TDTestCase:
|
|||
|
||||
def spellCheckCase(self):
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
stb_name = tdCom.getLongName(8, "letters")
|
||||
input_json_list = [{"metric": f'{stb_name}_1', "timestamp": {"value": 1626006833639000000, "type": "Ns"}, "value": {"value": 1, "type": "Bigint"}, "tags": {"t1": {"value": 127, "type": "tinYint"}}},
|
||||
{"metric": f'{stb_name}_2', "timestamp": {"value": 1626006833639000001, "type": "nS"}, "value": {"value": 32767, "type": "smallInt"}, "tags": {"t1": {"value": 32767, "type": "smallInt"}}},
|
||||
|
@ -1426,7 +1426,7 @@ class TDTestCase:
|
|||
|
||||
def tbnameTagsColsNameCheckCase(self):
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json = {'metric': 'rFa$sta', 'timestamp': {'value': 1626006834, 'type': 's'}, 'value': {'value': True, 'type': 'bool'}, 'tags': {'Tt!0': {'value': False, 'type': 'bool'}, 'tT@1': {'value': 127, 'type': 'tinyint'}, 't@2': {'value': 32767, 'type': 'smallint'}, 't$3': {'value': 2147483647, 'type': 'int'}, 't%4': {'value': 9223372036854775807, 'type': 'bigint'}, 't^5': {'value': 11.12345027923584, 'type': 'float'}, 't&6': {'value': 22.123456789, 'type': 'double'}, 't*7': {'value': 'binaryTagValue', 'type': 'binary'}, 't!@#$%^&*()_+[];:<>?,9': {'value': 'ncharTagValue', 'type': 'nchar'}, 'id': 'rFas$ta_1'}}
|
||||
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
query_sql = 'select * from `rFa$sta`'
|
||||
|
@ -1441,7 +1441,7 @@ class TDTestCase:
|
|||
metric value "." trans to "_"
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json = self.genFullTypeJson(point_trans_tag=True, value_type=value_type)[0]
|
||||
self._conn.schemaless_insert([json.dumps(input_json)], TDSmlProtocolType.JSON.value, None)
|
||||
tdSql.execute("drop table `.point.trans.test`")
|
||||
|
@ -1509,7 +1509,7 @@ class TDTestCase:
|
|||
thread input different stb
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json = self.genSqlList(value_type=value_type)[0]
|
||||
self.multiThreadRun(self.genMultiThreadSeq(input_json))
|
||||
tdSql.query(f"show tables;")
|
||||
|
@ -1520,7 +1520,7 @@ class TDTestCase:
|
|||
thread input same stb tb, different data, result keep first data
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary", value_type=value_type))
|
||||
self.resCmp(input_json, stb_name)
|
||||
|
@ -1538,7 +1538,7 @@ class TDTestCase:
|
|||
thread input same stb tb, different data, add columes and tags, result keep first data
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary", value_type=value_type))
|
||||
self.resCmp(input_json, stb_name)
|
||||
|
@ -1556,7 +1556,7 @@ class TDTestCase:
|
|||
thread input same stb tb, different data, minus columes and tags, result keep first data
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary", value_type=value_type))
|
||||
self.resCmp(input_json, stb_name)
|
||||
|
@ -1574,7 +1574,7 @@ class TDTestCase:
|
|||
thread input same stb, different tb, different data
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value="binaryTagValue", t_type="binary", value_type=value_type))
|
||||
self.resCmp(input_json, stb_name)
|
||||
s_stb_d_tb_list = self.genSqlList(stb_name=stb_name, value_type=value_type)[4]
|
||||
|
@ -1587,7 +1587,7 @@ class TDTestCase:
|
|||
thread input same stb, different tb, different data, add col, mul tag
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value="binaryTagValue", t_type="binary"))
|
||||
self.resCmp(input_json, stb_name)
|
||||
s_stb_d_tb_m_tag_list = [({"metric": stb_name, "timestamp": {"value": 1626006833639000000, "type": "ns"}, "value": "omfdhyom", "tags": {"t0": {"value": False, "type": "bool"}, "t1": {"value": 127, "type": "tinyint"}, "t2": {"value": 32767, "type": "smallint"}, "t3": {"value": 2147483647, "type": "int"}, "t4": {"value": 9223372036854775807, "type": "bigint"}, "t5": {"value": 11.12345, "type": "float"}, "t6": {"value": 22.123456789, "type": "double"}}}, 'yzwswz'),
|
||||
|
@ -1605,7 +1605,7 @@ class TDTestCase:
|
|||
thread input same stb, different tb, different data, add tag, mul col
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value="binaryTagValue", t_type="binary", value_type=value_type))
|
||||
self.resCmp(input_json, stb_name)
|
||||
s_stb_d_tb_a_tag_list = self.genSqlList(stb_name=stb_name, value_type=value_type)[6]
|
||||
|
@ -1618,7 +1618,7 @@ class TDTestCase:
|
|||
thread input same stb tb, different ts
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary"))
|
||||
self.resCmp(input_json, stb_name)
|
||||
|
@ -1638,7 +1638,7 @@ class TDTestCase:
|
|||
thread input same stb tb, different ts, add col, mul tag
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary"))
|
||||
self.resCmp(input_json, stb_name)
|
||||
|
@ -1660,7 +1660,7 @@ class TDTestCase:
|
|||
thread input same stb tb, different ts, add tag, mul col
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_json, stb_name = self.genFullTypeJson(tb_name=tb_name, col_value=self.genTsColValue(value="binaryTagValue", t_type="binary"))
|
||||
self.resCmp(input_json, stb_name)
|
||||
|
@ -1683,7 +1683,7 @@ class TDTestCase:
|
|||
thread input same stb, different tb, data, ts
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value="binaryTagValue", t_type="binary", value_type=value_type))
|
||||
self.resCmp(input_json, stb_name)
|
||||
s_stb_d_tb_d_ts_list = self.genSqlList(stb_name=stb_name, value_type=value_type)[10]
|
||||
|
@ -1696,7 +1696,7 @@ class TDTestCase:
|
|||
thread input same stb, different tb, data, ts, add col, mul tag
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_json, stb_name = self.genFullTypeJson(col_value=self.genTsColValue(value="binaryTagValue", t_type="binary"))
|
||||
self.resCmp(input_json, stb_name)
|
||||
s_stb_d_tb_d_ts_m_tag_list = [({'metric': stb_name, 'timestamp': {'value': 0, 'type': 'ns'}, 'value': 'pjndapjb', 'tags': {'t0': {'value': False, 'type': 'bool'}, 't1': {'value': 127, 'type': 'tinyint'}, 't2': {'value': 32767, 'type': 'smallint'}, 't3': {'value': 2147483647, 'type': 'int'}, 't4': {"value": 9223372036854775807, "type": "bigint"}, 't5': {'value': 11.12345027923584, 'type': 'float'}, 't6': {'value': 22.123456789, 'type': 'double'}}}, 'punftb'),
|
||||
|
|
|
@ -30,7 +30,7 @@ if platform.system().lower() == 'windows':
|
|||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
tdSql.init(conn.cursor(), False)
|
||||
self._conn = conn
|
||||
self.smlChildTableName_value = "id"
|
||||
|
||||
|
@ -351,7 +351,7 @@ class TDTestCase:
|
|||
normal tags and cols, one for every elm
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(protocol=protocol)
|
||||
self.resCmp(input_sql, stb_name, protocol=protocol)
|
||||
|
||||
|
@ -360,7 +360,7 @@ class TDTestCase:
|
|||
check all normal type
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
full_type_list = ["f", "F", "false", "False", "t", "T", "true", "True"]
|
||||
for t_type in full_type_list:
|
||||
input_sql, stb_name = self.genFullTypeSql(t0=t_type, protocol=protocol)
|
||||
|
@ -375,7 +375,7 @@ class TDTestCase:
|
|||
binary_symbols = '\"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"\'\'"\"'
|
||||
'''
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
binary_symbols = '"abcd`~!@#$%^&*()_-{[}]|:;<.>?lfjal"'
|
||||
nchar_symbols = f'L{binary_symbols}'
|
||||
input_sql1, stb_name1 = self.genFullTypeSql(value=binary_symbols, t7=binary_symbols, t8=nchar_symbols, protocol=protocol)
|
||||
|
@ -388,7 +388,7 @@ class TDTestCase:
|
|||
test ts list --> ["1626006833640ms", "1626006834s", "1626006822639022"]
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(ts=1626006833640)
|
||||
self.resCmp(input_sql, stb_name, ts_type=TDSmlTimestampType.MILLI_SECOND.value)
|
||||
input_sql, stb_name = self.genFullTypeSql(ts=1626006833640)
|
||||
|
@ -407,7 +407,7 @@ class TDTestCase:
|
|||
|
||||
def openTstbTelnetTsCheckCase(self):
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = f'{tdCom.getLongName(len=10, mode="letters")} 0 127 t0=127 t1=32767I16 t2=2147483647I32 t3=9223372036854775807 t4=11.12345027923584F32 t5=22.123456789F64'
|
||||
stb_name = input_sql.split(" ")[0]
|
||||
self.resCmp(input_sql, stb_name, ts=0)
|
||||
|
@ -431,7 +431,7 @@ class TDTestCase:
|
|||
eg: t0=**,id=**,t1=**
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(id_change_tag=True, protocol=protocol)
|
||||
self.resCmp(input_sql, stb_name, protocol=protocol)
|
||||
|
||||
|
@ -441,7 +441,7 @@ class TDTestCase:
|
|||
eg: id and ID
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(id_upper_tag=True, protocol=protocol)
|
||||
self.resCmp(input_sql, stb_name, protocol=protocol)
|
||||
input_sql, stb_name = self.genFullTypeSql(id_mixul_tag=True, protocol=protocol)
|
||||
|
@ -454,7 +454,7 @@ class TDTestCase:
|
|||
id not exist
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(id_noexist_tag=True, protocol=protocol)
|
||||
self.resCmp(input_sql, stb_name, protocol=protocol)
|
||||
query_sql = f"select tbname from {stb_name}"
|
||||
|
@ -470,10 +470,10 @@ class TDTestCase:
|
|||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
for input_sql in [self.genLongSql(128)[0]]:
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
for input_sql in [self.genLongSql(129)[0]]:
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
try:
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
raise Exception("should not reach here")
|
||||
|
@ -486,7 +486,7 @@ class TDTestCase:
|
|||
mix "`~!@#$¥%^&*()-+{}|[]、「」【】:;《》<>?"
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
rstr = list("~!@#$¥%^&*()-+{}|[]、「」【】:;《》<>?")
|
||||
for i in rstr:
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name=f"\"aaa{i}bbb\"", protocol=protocol)
|
||||
|
@ -498,7 +498,7 @@ class TDTestCase:
|
|||
id is start with num
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name="1aaabbb", protocol=protocol)
|
||||
self.resCmp(input_sql, stb_name, protocol=protocol)
|
||||
|
||||
|
@ -507,7 +507,7 @@ class TDTestCase:
|
|||
check now unsupported
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = self.genFullTypeSql(ts="now")[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
|
@ -520,7 +520,7 @@ class TDTestCase:
|
|||
check date format ts unsupported
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = self.genFullTypeSql(ts="2021-07-21\ 19:01:46.920")[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
|
@ -533,7 +533,7 @@ class TDTestCase:
|
|||
check ts format like 16260068336390us19
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = self.genFullTypeSql(ts="16260068336390us19")[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
|
@ -551,7 +551,7 @@ class TDTestCase:
|
|||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
stb_name_192 = tdCom.getLongName(len=192, mode="letters")
|
||||
tb_name_192 = tdCom.getLongName(len=192, mode="letters")
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name_192, tb_name=tb_name_192)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
tdSql.query(f'select * from {stb_name}')
|
||||
|
@ -581,7 +581,7 @@ class TDTestCase:
|
|||
check tag name limit <= 62
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tag_name = tdCom.getLongName(61, "letters")
|
||||
tag_name = f'T{tag_name}'
|
||||
stb_name = tdCom.getLongName(7, "letters")
|
||||
|
@ -599,7 +599,7 @@ class TDTestCase:
|
|||
check full type tag value limit
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
# nchar
|
||||
# * legal nchar could not be larger than 16374/4
|
||||
stb_name = tdCom.getLongName(7, "letters")
|
||||
|
@ -618,12 +618,12 @@ class TDTestCase:
|
|||
check full type col value limit
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
# i8
|
||||
for value in ["-128i8", "127i8"]:
|
||||
input_sql, stb_name = self.genFullTypeSql(value=value)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in ["-129i8", "128i8"]:
|
||||
input_sql = self.genFullTypeSql(value=value)[0]
|
||||
try:
|
||||
|
@ -632,11 +632,11 @@ class TDTestCase:
|
|||
except SchemalessError as err:
|
||||
tdSql.checkNotEqual(err.errno, 0)
|
||||
# i16
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in ["-32768i16"]:
|
||||
input_sql, stb_name = self.genFullTypeSql(value=value)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in ["-32769i16", "32768i16"]:
|
||||
input_sql = self.genFullTypeSql(value=value)[0]
|
||||
try:
|
||||
|
@ -646,11 +646,11 @@ class TDTestCase:
|
|||
tdSql.checkNotEqual(err.errno, 0)
|
||||
|
||||
# i32
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in ["-2147483648i32"]:
|
||||
input_sql, stb_name = self.genFullTypeSql(value=value)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in ["-2147483649i32", "2147483648i32"]:
|
||||
input_sql = self.genFullTypeSql(value=value)[0]
|
||||
try:
|
||||
|
@ -660,11 +660,11 @@ class TDTestCase:
|
|||
tdSql.checkNotEqual(err.errno, 0)
|
||||
|
||||
# i64
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in ["-9223372036854775808i64"]:
|
||||
input_sql, stb_name = self.genFullTypeSql(value=value)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in ["-9223372036854775809i64", "9223372036854775808i64"]:
|
||||
input_sql = self.genFullTypeSql(value=value)[0]
|
||||
try:
|
||||
|
@ -674,12 +674,12 @@ class TDTestCase:
|
|||
tdSql.checkNotEqual(err.errno, 0)
|
||||
|
||||
# f32
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in [f"{-3.4028234663852885981170418348451692544*(10**38)}f32", f"{3.4028234663852885981170418348451692544*(10**38)}f32"]:
|
||||
input_sql, stb_name = self.genFullTypeSql(value=value)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
# * limit set to 4028234664*(10**38)
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in [f"{-3.4028234664*(10**38)}f32", f"{3.4028234664*(10**38)}f32"]:
|
||||
input_sql = self.genFullTypeSql(value=value)[0]
|
||||
try:
|
||||
|
@ -689,12 +689,12 @@ class TDTestCase:
|
|||
tdSql.checkNotEqual(err.errno, 0)
|
||||
|
||||
# f64
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
for value in [f'{-1.79769313486231570814527423731704356798070567525844996598917476803157260780*(10**308)}f64', f'{-1.79769313486231570814527423731704356798070567525844996598917476803157260780*(10**308)}f64']:
|
||||
input_sql, stb_name = self.genFullTypeSql(value=value)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
# # * limit set to 1.797693134862316*(10**308)
|
||||
# tdCom.cleanTb()
|
||||
# tdCom.cleanTb(dbname="test")
|
||||
# for value in [f'{-1.797693134862316*(10**308)}f64', f'{-1.797693134862316*(10**308)}f64']:
|
||||
# input_sql = self.genFullTypeSql(value=value)[0]
|
||||
# try:
|
||||
|
@ -704,12 +704,12 @@ class TDTestCase:
|
|||
# tdSql.checkNotEqual(err.errno, 0)
|
||||
|
||||
# # # binary
|
||||
# tdCom.cleanTb()
|
||||
# tdCom.cleanTb(dbname="test")
|
||||
# stb_name = tdCom.getLongName(7, "letters")
|
||||
# input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16374, "letters")}" t0=t'
|
||||
# self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
|
||||
# tdCom.cleanTb()
|
||||
# tdCom.cleanTb(dbname="test")
|
||||
# input_sql = f'{stb_name} 1626006833640 "{tdCom.getLongName(16375, "letters")}" t0=t'
|
||||
# try:
|
||||
# self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
|
@ -719,12 +719,12 @@ class TDTestCase:
|
|||
|
||||
# # nchar
|
||||
# # * legal nchar could not be larger than 16374/4
|
||||
# tdCom.cleanTb()
|
||||
# tdCom.cleanTb(dbname="test")
|
||||
# stb_name = tdCom.getLongName(7, "letters")
|
||||
# input_sql = f'{stb_name} 1626006833640 L"{tdCom.getLongName(4093, "letters")}" t0=t'
|
||||
# self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
|
||||
# tdCom.cleanTb()
|
||||
# tdCom.cleanTb(dbname="test")
|
||||
# input_sql = f'{stb_name} 1626006833640 L"{tdCom.getLongName(4094, "letters")}" t0=t'
|
||||
# try:
|
||||
# self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
|
@ -738,7 +738,7 @@ class TDTestCase:
|
|||
test illegal tag col value
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
# bool
|
||||
for i in ["TrUe", "tRue", "trUe", "truE", "FalsE", "fAlse", "faLse", "falSe", "falsE"]:
|
||||
input_sql1, stb_name = self.genFullTypeSql(t0=i)
|
||||
|
@ -774,7 +774,7 @@ class TDTestCase:
|
|||
check blank case
|
||||
'''
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
# input_sql_list = [f'{tdCom.getLongName(7, "letters")} 1626006833640 "abc aaa" t0=t',
|
||||
# f'{tdCom.getLongName(7, "letters")} 1626006833640 t t0="abaaa"',
|
||||
# f'{tdCom.getLongName(7, "letters")} 1626006833640 t t0=L"abaaa"',
|
||||
|
@ -792,7 +792,7 @@ class TDTestCase:
|
|||
check duplicate Id Tag Col
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql_id = self.genFullTypeSql(id_double_tag=True)[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([input_sql_id], TDSmlProtocolType.TELNET.value, None)
|
||||
|
@ -815,7 +815,7 @@ class TDTestCase:
|
|||
case no id when stb exist
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name="sub_table_0123456", t0="f", value="f")
|
||||
self.resCmp(input_sql, stb_name)
|
||||
input_sql, stb_name = self.genFullTypeSql(stb_name=stb_name, id_noexist_tag=True, t0="f", value="f")
|
||||
|
@ -828,7 +828,7 @@ class TDTestCase:
|
|||
check duplicate insert when stb exist
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql()
|
||||
self.resCmp(input_sql, stb_name)
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
|
@ -840,7 +840,7 @@ class TDTestCase:
|
|||
check length increase
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql()
|
||||
self.resCmp(input_sql, stb_name)
|
||||
tb_name = tdCom.getLongName(5, "letters")
|
||||
|
@ -858,7 +858,7 @@ class TDTestCase:
|
|||
* col is added with value when update==1
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
for db_update_tag in [0, 1]:
|
||||
if db_update_tag == 1 :
|
||||
|
@ -885,7 +885,7 @@ class TDTestCase:
|
|||
check tag count add
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, t0="f", value="f")
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
@ -902,7 +902,7 @@ class TDTestCase:
|
|||
insert two table, keep tag unchange, change col
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(t0="f", value="f", id_noexist_tag=True)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
tb_name1 = self.getNoIdTbName(stb_name)
|
||||
|
@ -925,7 +925,7 @@ class TDTestCase:
|
|||
check nchar length limit
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
stb_name = tdCom.getLongName(7, "letters")
|
||||
input_sql = f'{stb_name} 1626006833640 f t2={tdCom.getLongName(1, "letters")}'
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
|
@ -949,7 +949,7 @@ class TDTestCase:
|
|||
test batch insert
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
stb_name = tdCom.getLongName(8, "letters")
|
||||
tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 bigint)')
|
||||
|
||||
|
@ -976,7 +976,7 @@ class TDTestCase:
|
|||
test multi insert
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
sql_list = []
|
||||
stb_name = tdCom.getLongName(8, "letters")
|
||||
tdSql.execute(f'create stable {stb_name}(ts timestamp, f int) tags(t1 nchar(10))')
|
||||
|
@ -992,7 +992,7 @@ class TDTestCase:
|
|||
test batch error insert
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
stb_name = tdCom.getLongName(8, "letters")
|
||||
lines = ["st123456 1626006833640 3i 64 t1=3i64 t2=4f64 t3=\"t3\"",
|
||||
f"{stb_name} 1626056811823316532ns tRue t2=5f64 t3=L\"ste\""]
|
||||
|
@ -1007,7 +1007,7 @@ class TDTestCase:
|
|||
test multi cols insert
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = self.genFullTypeSql(c_multi_tag=True)[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
|
@ -1020,7 +1020,7 @@ class TDTestCase:
|
|||
test blank col insert
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = self.genFullTypeSql(c_blank_tag=True)[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
|
@ -1033,7 +1033,7 @@ class TDTestCase:
|
|||
test blank tag insert
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = self.genFullTypeSql(t_blank_tag=True)[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
|
@ -1046,7 +1046,7 @@ class TDTestCase:
|
|||
check nchar ---> chinese
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(chinese_tag=True)
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
||||
|
@ -1055,7 +1055,7 @@ class TDTestCase:
|
|||
multi_field
|
||||
'''
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = self.genFullTypeSql(multi_field_tag=True)[0]
|
||||
try:
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
|
@ -1065,7 +1065,7 @@ class TDTestCase:
|
|||
|
||||
def spellCheckCase(self):
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
stb_name = tdCom.getLongName(8, "letters")
|
||||
input_sql_list = [f'{stb_name}_1 1626006833640 127I8 t0=127I8 t1=32767I16 t2=2147483647I32 t3=9223372036854775807I64 t4=11.12345027923584F32 t5=22.123456789F64',
|
||||
f'{stb_name}_2 1626006833640 32767I16 t0=127I8 t1=32767I16 t2=2147483647I32 t3=9223372036854775807I64 t4=11.12345027923584F32 t5=22.123456789F64',
|
||||
|
@ -1086,7 +1086,7 @@ class TDTestCase:
|
|||
metric value "." trans to "_"
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = self.genFullTypeSql(point_trans_tag=True, protocol=protocol)[0]
|
||||
if protocol == 'telnet-tcp':
|
||||
stb_name = f'`{input_sql.split(" ")[1]}`'
|
||||
|
@ -1097,7 +1097,7 @@ class TDTestCase:
|
|||
|
||||
def defaultTypeCheckCase(self):
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
stb_name = tdCom.getLongName(8, "letters")
|
||||
input_sql_list = [f'{stb_name}_1 1626006833640 9223372036854775807 t0=f t1=127 t2=32767i16 t3=2147483647i32 t4=9223372036854775807 t5=11.12345f32 t6=22.123456789f64 t7="vozamcts" t8=L"ncharTagValue"', \
|
||||
f'{stb_name}_2 1626006833641 22.123456789 t0=f t1=127i8 t2=32767I16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789 t7="vozamcts" t8=L"ncharTagValue"', \
|
||||
|
@ -1110,7 +1110,7 @@ class TDTestCase:
|
|||
|
||||
def tbnameTagsColsNameCheckCase(self):
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
if self.smlChildTableName_value == "ID":
|
||||
input_sql = 'rFa$sta 1626006834 9223372036854775807 id=rFas$ta_1 Tt!0=true tT@1=127Ii8 t#2=32767i16 "t$3"=2147483647i32 t%4=9223372036854775807i64 t^5=11.12345f32 t&6=22.123456789f64 t*7=\"ddzhiksj\" t!@#$%^&*()_+[];:<>?,9=L\"ncharTagValue\"'
|
||||
self._conn.schemaless_insert([input_sql], TDSmlProtocolType.TELNET.value, None)
|
||||
|
@ -1135,7 +1135,7 @@ class TDTestCase:
|
|||
stb = "put"
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = self.genFullTypeSql(tcp_keyword_tag=True, protocol=protocol)[0]
|
||||
stb_name = f'`{input_sql.split(" ")[1]}`'
|
||||
self.resCmp(input_sql, stb_name, protocol=protocol)
|
||||
|
@ -1204,7 +1204,7 @@ class TDTestCase:
|
|||
thread input different stb
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql = self.genSqlList()[0]
|
||||
print(input_sql)
|
||||
self.multiThreadRun(self.genMultiThreadSeq(input_sql))
|
||||
|
@ -1216,7 +1216,7 @@ class TDTestCase:
|
|||
thread input same stb tb, different data, result keep first data
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"")
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
@ -1235,7 +1235,7 @@ class TDTestCase:
|
|||
thread input same stb tb, different data, add columes and tags, result keep first data
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"")
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
@ -1254,7 +1254,7 @@ class TDTestCase:
|
|||
thread input same stb tb, different data, minus columes and tags, result keep first data
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"")
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
@ -1273,7 +1273,7 @@ class TDTestCase:
|
|||
thread input same stb, different tb, different data
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"")
|
||||
self.resCmp(input_sql, stb_name)
|
||||
s_stb_d_tb_list = self.genSqlList(stb_name=stb_name)[4]
|
||||
|
@ -1286,7 +1286,7 @@ class TDTestCase:
|
|||
thread input same stb, different tb, different data, add col, mul tag
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"")
|
||||
self.resCmp(input_sql, stb_name)
|
||||
s_stb_d_tb_m_tag_list = [(f'{stb_name} 1626006833640 "omfdhyom" t0=F t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'yzwswz'), \
|
||||
|
@ -1303,7 +1303,7 @@ class TDTestCase:
|
|||
thread input same stb, different tb, different data, add tag, mul col
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"")
|
||||
self.resCmp(input_sql, stb_name)
|
||||
s_stb_d_tb_a_tag_list = self.genSqlList(stb_name=stb_name)[6]
|
||||
|
@ -1316,7 +1316,7 @@ class TDTestCase:
|
|||
thread input same stb tb, different ts
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"")
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
@ -1336,7 +1336,7 @@ class TDTestCase:
|
|||
thread input same stb tb, different ts, add col, mul tag
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"")
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
@ -1354,7 +1354,7 @@ class TDTestCase:
|
|||
thread input same stb tb, different ts, add tag, mul col
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
tb_name = tdCom.getLongName(7, "letters")
|
||||
input_sql, stb_name = self.genFullTypeSql(tb_name=tb_name, value="\"binaryTagValue\"")
|
||||
self.resCmp(input_sql, stb_name)
|
||||
|
@ -1377,7 +1377,7 @@ class TDTestCase:
|
|||
thread input same stb, different tb, data, ts
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"")
|
||||
self.resCmp(input_sql, stb_name)
|
||||
s_stb_d_tb_d_ts_list = self.genSqlList(stb_name=stb_name)[10]
|
||||
|
@ -1390,7 +1390,7 @@ class TDTestCase:
|
|||
thread input same stb, different tb, data, ts, add col, mul tag
|
||||
"""
|
||||
tdLog.info(f'{sys._getframe().f_code.co_name}() function is running')
|
||||
tdCom.cleanTb()
|
||||
tdCom.cleanTb(dbname="test")
|
||||
input_sql, stb_name = self.genFullTypeSql(value="\"binaryTagValue\"")
|
||||
self.resCmp(input_sql, stb_name)
|
||||
s_stb_d_tb_d_ts_m_tag_list = [(f'{stb_name} 0 "mnpmtzul" t0=False t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64', 'pcppkg'), \
|
||||
|
|
|
@ -193,43 +193,38 @@ class TDTestCase:
|
|||
|
||||
# case17: only support normal table join
|
||||
case17 = {
|
||||
"col": "t1.c1",
|
||||
"table_expr": "t1, t2",
|
||||
"condition": "where t1.ts=t2.ts"
|
||||
"col": "table1.c1 ",
|
||||
"table_expr": "db.t1 as table1, db.t2 as table2",
|
||||
"condition": "where table1.ts=table2.ts"
|
||||
}
|
||||
self.checkdiff(**case17)
|
||||
# case18~19: with group by
|
||||
# case18 = {
|
||||
# "table_expr": "db.t1",
|
||||
# "condition": "group by c6"
|
||||
# }
|
||||
# self.checkdiff(**case18)
|
||||
# case18~19: with group by , function diff not support group by
|
||||
|
||||
case19 = {
|
||||
"table_expr": "db.stb1",
|
||||
"table_expr": "db.stb1 where tbname =='t0' ",
|
||||
"condition": "partition by tbname order by tbname" # partition by tbname
|
||||
}
|
||||
self.checkdiff(**case19)
|
||||
|
||||
# # case20~21: with order by
|
||||
# case20 = {"condition": "order by ts"}
|
||||
# self.checkdiff(**case20)
|
||||
# case20~21: with order by , Not a single-group group function
|
||||
|
||||
# # case22: with union
|
||||
# case22: with union
|
||||
# case22 = {
|
||||
# "condition": "union all select diff(c1) from t2"
|
||||
# "condition": "union all select diff(c1) from db.t2 "
|
||||
# }
|
||||
# self.checkdiff(**case22)
|
||||
tdSql.query("select count(c1) from db.t1 union all select count(c1) from db.t2")
|
||||
|
||||
# case23: with limit/slimit
|
||||
case23 = {
|
||||
"condition": "limit 1"
|
||||
}
|
||||
self.checkdiff(**case23)
|
||||
# case24 = {
|
||||
# "table_expr": "db.stb1",
|
||||
# "condition": "group by tbname slimit 1 soffset 1"
|
||||
# }
|
||||
# self.checkdiff(**case24)
|
||||
case24 = {
|
||||
"table_expr": "db.stb1",
|
||||
"condition": "partition by tbname order by tbname slimit 1 soffset 1"
|
||||
}
|
||||
self.checkdiff(**case24)
|
||||
|
||||
pass
|
||||
|
||||
|
@ -284,9 +279,9 @@ class TDTestCase:
|
|||
tdSql.query(self.diff_query_form(alias=", c2")) # mix with other 1
|
||||
# tdSql.error(self.diff_query_form(table_expr="db.stb1")) # select stb directly
|
||||
stb_join = {
|
||||
"col": "stb1.c1",
|
||||
"table_expr": "stb1, stb2",
|
||||
"condition": "where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts"
|
||||
"col": "stable1.c1",
|
||||
"table_expr": "db.stb1 as stable1, db.stb2 as stable2",
|
||||
"condition": "where stable1.ts=stable2.ts and stable1.st1=stable2.st2 order by stable1.ts"
|
||||
}
|
||||
tdSql.query(self.diff_query_form(**stb_join)) # stb join
|
||||
interval_sql = {
|
||||
|
@ -315,20 +310,20 @@ class TDTestCase:
|
|||
for i in range(tbnum):
|
||||
for j in range(data_row):
|
||||
tdSql.execute(
|
||||
f"insert into t{i} values ("
|
||||
f"insert into db.t{i} values ("
|
||||
f"{basetime + (j+1)*10}, {random.randint(-200, -1)}, {random.uniform(200, -1)}, {basetime + random.randint(-200, -1)}, "
|
||||
f"'binary_{j}', {random.uniform(-200, -1)}, {random.choice([0,1])}, {random.randint(-200,-1)}, "
|
||||
f"{random.randint(-200, -1)}, {random.randint(-127, -1)}, 'nchar_{j}' )"
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
f"insert into t{i} values ("
|
||||
f"insert into db.t{i} values ("
|
||||
f"{basetime - (j+1) * 10}, {random.randint(1, 200)}, {random.uniform(1, 200)}, {basetime - random.randint(1, 200)}, "
|
||||
f"'binary_{j}_1', {random.uniform(1, 200)}, {random.choice([0, 1])}, {random.randint(1,200)}, "
|
||||
f"{random.randint(1,200)}, {random.randint(1,127)}, 'nchar_{j}_1' )"
|
||||
)
|
||||
tdSql.execute(
|
||||
f"insert into tt{i} values ( {basetime-(j+1) * 10}, {random.randint(1, 200)} )"
|
||||
f"insert into db.tt{i} values ( {basetime-(j+1) * 10}, {random.randint(1, 200)} )"
|
||||
)
|
||||
|
||||
pass
|
||||
|
@ -349,8 +344,8 @@ class TDTestCase:
|
|||
"create stable db.stb2 (ts timestamp, c1 int) tags(st2 int)"
|
||||
)
|
||||
for i in range(tbnum):
|
||||
tdSql.execute(f"create table t{i} using db.stb1 tags({i})")
|
||||
tdSql.execute(f"create table tt{i} using db.stb2 tags({i})")
|
||||
tdSql.execute(f"create table db.t{i} using db.stb1 tags({i})")
|
||||
tdSql.execute(f"create table db.tt{i} using db.stb2 tags({i})")
|
||||
|
||||
pass
|
||||
def diff_support_stable(self):
|
||||
|
@ -398,8 +393,8 @@ class TDTestCase:
|
|||
|
||||
tdLog.printNoPrefix("######## insert only NULL test:")
|
||||
for i in range(tbnum):
|
||||
tdSql.execute(f"insert into t{i}(ts) values ({nowtime - 5})")
|
||||
tdSql.execute(f"insert into t{i}(ts) values ({nowtime + 5})")
|
||||
tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime - 5})")
|
||||
tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime + 5})")
|
||||
self.diff_current_query()
|
||||
self.diff_error_query()
|
||||
|
||||
|
@ -430,9 +425,9 @@ class TDTestCase:
|
|||
|
||||
tdLog.printNoPrefix("######## insert data mix with NULL test:")
|
||||
for i in range(tbnum):
|
||||
tdSql.execute(f"insert into t{i}(ts) values ({nowtime})")
|
||||
tdSql.execute(f"insert into t{i}(ts) values ({nowtime-(per_table_rows+3)*10})")
|
||||
tdSql.execute(f"insert into t{i}(ts) values ({nowtime+(per_table_rows+3)*10})")
|
||||
tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime})")
|
||||
tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime-(per_table_rows+3)*10})")
|
||||
tdSql.execute(f"insert into db.t{i}(ts) values ({nowtime+(per_table_rows+3)*10})")
|
||||
self.diff_current_query()
|
||||
self.diff_error_query()
|
||||
|
||||
|
|
|
@ -52,12 +52,12 @@ class TDTestCase:
|
|||
|
||||
return query_condition
|
||||
|
||||
def __join_condition(self, tb_list, filter=PRIMARY_COL, INNER=False):
|
||||
def __join_condition(self, tb_list, filter=PRIMARY_COL, INNER=False, alias_tb1="tb1", alias_tb2="tb2"):
|
||||
table_reference = tb_list[0]
|
||||
join_condition = table_reference
|
||||
join = "inner join" if INNER else "join"
|
||||
for i in range(len(tb_list[1:])):
|
||||
join_condition += f" {join} {tb_list[i+1]} on {table_reference}.{filter}={tb_list[i+1]}.{filter}"
|
||||
join_condition += f" as {alias_tb1} {join} {tb_list[i+1]} as {alias_tb2} on {alias_tb1}.{filter}={alias_tb2}.{filter}"
|
||||
|
||||
return join_condition
|
||||
|
||||
|
@ -123,28 +123,28 @@ class TDTestCase:
|
|||
sqls = []
|
||||
__join_tblist = self.__join_tblist
|
||||
for join_tblist in __join_tblist:
|
||||
for join_tb in join_tblist:
|
||||
select_claus_list = self.__query_condition(join_tb)
|
||||
for select_claus in select_claus_list:
|
||||
group_claus = self.__group_condition( col=select_claus)
|
||||
where_claus = self.__where_condition( query_conditon=select_claus )
|
||||
having_claus = self.__group_condition( col=select_claus, having=f"{select_claus} is not null" )
|
||||
sqls.extend(
|
||||
(
|
||||
# self.__gen_sql(select_claus, self.__join_condition(join_tblist), where_claus, group_claus),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist), where_claus, having_claus),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist), where_claus),
|
||||
# self.__gen_sql(select_claus, self.__join_condition(join_tblist), group_claus),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist), having_claus),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist)),
|
||||
# self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), where_claus, group_claus),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), where_claus, having_claus),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), where_claus, ),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), having_claus ),
|
||||
# self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), group_claus ),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True) ),
|
||||
)
|
||||
alias_tb = "tb1"
|
||||
select_claus_list = self.__query_condition(alias_tb)
|
||||
for select_claus in select_claus_list:
|
||||
group_claus = self.__group_condition( col=select_claus)
|
||||
where_claus = self.__where_condition( query_conditon=select_claus )
|
||||
having_claus = self.__group_condition( col=select_claus, having=f"{select_claus} is not null" )
|
||||
sqls.extend(
|
||||
(
|
||||
# self.__gen_sql(select_claus, self.__join_condition(join_tblist), where_claus, group_claus),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb), where_claus, having_claus),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb), where_claus),
|
||||
# self.__gen_sql(select_claus, self.__join_condition(join_tblist), group_claus),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb), having_claus),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb)),
|
||||
# self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), where_claus, group_claus),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb, INNER=True), where_claus, having_claus),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb, INNER=True), where_claus, ),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb, INNER=True), having_claus ),
|
||||
# self.__gen_sql(select_claus, self.__join_condition(join_tblist, INNER=True), group_claus ),
|
||||
self.__gen_sql(select_claus, self.__join_condition(join_tblist, alias_tb1=alias_tb, INNER=True) ),
|
||||
)
|
||||
)
|
||||
return list(filter(None, sqls))
|
||||
|
||||
def __join_check(self,):
|
||||
|
@ -341,10 +341,8 @@ class TDTestCase:
|
|||
tdLog.printNoPrefix("==========step3:all check")
|
||||
self.all_test()
|
||||
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.execute(f"flush database db")
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
||||
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
||||
self.all_test()
|
||||
|
|
|
@ -65,8 +65,7 @@ class TDTestCase:
|
|||
'''
|
||||
)
|
||||
|
||||
|
||||
def check_result_auto_log(self ,origin_query , log_query):
|
||||
def check_result_auto_log(self ,base , origin_query , log_query):
|
||||
|
||||
log_result = tdSql.getResult(log_query)
|
||||
origin_result = tdSql.getResult(origin_query)
|
||||
|
@ -76,113 +75,30 @@ class TDTestCase:
|
|||
for row in origin_result:
|
||||
row_check = []
|
||||
for elem in row:
|
||||
if elem == None:
|
||||
elem = None
|
||||
elif elem >0:
|
||||
elem = math.log(elem)
|
||||
elif elem <=0:
|
||||
if base ==1:
|
||||
elem = None
|
||||
else:
|
||||
if elem == None:
|
||||
elem = None
|
||||
elif elem ==1:
|
||||
elem = 0.0
|
||||
elif elem >0 and elem !=1 :
|
||||
if base==None :
|
||||
elem = math.log(elem )
|
||||
else:
|
||||
print(base , elem)
|
||||
elem = math.log(elem , base)
|
||||
elif elem <=0:
|
||||
elem = None
|
||||
|
||||
row_check.append(elem)
|
||||
auto_result.append(row_check)
|
||||
|
||||
check_status = True
|
||||
tdSql.query(log_query)
|
||||
for row_index , row in enumerate(log_result):
|
||||
for col_index , elem in enumerate(row):
|
||||
if auto_result[row_index][col_index] != elem:
|
||||
check_status = False
|
||||
if not check_status:
|
||||
tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query )
|
||||
sys.exit(1)
|
||||
else:
|
||||
tdLog.info("log value check pass , it work as expected ,sql is \"%s\" "%log_query )
|
||||
|
||||
def check_result_auto_log2(self ,origin_query , log_query):
|
||||
|
||||
log_result = tdSql.getResult(log_query)
|
||||
origin_result = tdSql.getResult(origin_query)
|
||||
|
||||
auto_result =[]
|
||||
|
||||
for row in origin_result:
|
||||
row_check = []
|
||||
for elem in row:
|
||||
if elem == None:
|
||||
elem = None
|
||||
elif elem >0:
|
||||
elem = math.log(elem,2)
|
||||
elif elem <=0:
|
||||
elem = None
|
||||
row_check.append(elem)
|
||||
auto_result.append(row_check)
|
||||
|
||||
check_status = True
|
||||
for row_index , row in enumerate(log_result):
|
||||
for col_index , elem in enumerate(row):
|
||||
if auto_result[row_index][col_index] != elem:
|
||||
check_status = False
|
||||
if not check_status:
|
||||
tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query )
|
||||
sys.exit(1)
|
||||
else:
|
||||
tdLog.info("log value check pass , it work as expected ,sql is \"%s\" "%log_query )
|
||||
|
||||
def check_result_auto_log1(self ,origin_query , log_query):
|
||||
log_result = tdSql.getResult(log_query)
|
||||
origin_result = tdSql.getResult(origin_query)
|
||||
|
||||
auto_result =[]
|
||||
|
||||
for row in origin_result:
|
||||
row_check = []
|
||||
for elem in row:
|
||||
if elem == None:
|
||||
elem = None
|
||||
elif elem >0:
|
||||
elem = None
|
||||
elif elem <=0:
|
||||
elem = None
|
||||
row_check.append(elem)
|
||||
auto_result.append(row_check)
|
||||
|
||||
check_status = True
|
||||
for row_index , row in enumerate(log_result):
|
||||
for col_index , elem in enumerate(row):
|
||||
if auto_result[row_index][col_index] != elem:
|
||||
check_status = False
|
||||
if not check_status:
|
||||
tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query )
|
||||
sys.exit(1)
|
||||
else:
|
||||
tdLog.info("log value check pass , it work as expected ,sql is \"%s\" "%log_query )
|
||||
def check_result_auto_log__10(self ,origin_query , log_query):
|
||||
log_result = tdSql.getResult(log_query)
|
||||
origin_result = tdSql.getResult(origin_query)
|
||||
|
||||
auto_result =[]
|
||||
|
||||
for row in origin_result:
|
||||
row_check = []
|
||||
for elem in row:
|
||||
if elem == None:
|
||||
elem = None
|
||||
elif elem >0:
|
||||
elem = None
|
||||
elif elem <=0:
|
||||
elem = None
|
||||
row_check.append(elem)
|
||||
auto_result.append(row_check)
|
||||
|
||||
check_status = True
|
||||
for row_index , row in enumerate(log_result):
|
||||
for col_index , elem in enumerate(row):
|
||||
if auto_result[row_index][col_index] != elem:
|
||||
check_status = False
|
||||
if not check_status:
|
||||
tdLog.notice("log function value has not as expected , sql is \"%s\" "%log_query )
|
||||
sys.exit(1)
|
||||
else:
|
||||
tdLog.info("log value check pass , it work as expected ,sql is \"%s\" "%log_query )
|
||||
|
||||
tdSql.checkData(row_index , col_index ,auto_result[row_index][col_index])
|
||||
|
||||
def test_errors(self, dbname="db"):
|
||||
error_sql_lists = [
|
||||
f"select log from {dbname}.t1",
|
||||
|
@ -328,10 +244,10 @@ class TDTestCase:
|
|||
tdSql.checkData(3 , 0, 1.098612289)
|
||||
tdSql.checkData(4 , 0, 1.386294361)
|
||||
|
||||
self.check_result_auto_log( f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) from {dbname}.t1")
|
||||
self.check_result_auto_log2( f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,2), log(c2 ,2) ,log(c3, 2), log(c4 ,2), log(c5 ,2) from {dbname}.t1")
|
||||
self.check_result_auto_log__10( f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,1), log(c2 ,1) ,log(c3, 1), log(c4 ,1), log(c5 ,1) from {dbname}.t1")
|
||||
self.check_result_auto_log__10( f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,-10), log(c2 ,-10) ,log(c3, -10), log(c4 ,-10), log(c5 ,-10) from {dbname}.t1")
|
||||
self.check_result_auto_log( None , f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) from {dbname}.t1")
|
||||
self.check_result_auto_log( 2 , f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,2), log(c2 ,2) ,log(c3, 2), log(c4 ,2), log(c5 ,2) from {dbname}.t1")
|
||||
self.check_result_auto_log( 1, f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,1), log(c2 ,1) ,log(c3, 1), log(c4 ,1), log(c5 ,1) from {dbname}.t1")
|
||||
self.check_result_auto_log( 10 ,f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select log(c1 ,10), log(c2 ,10) ,log(c3, 10), log(c4 ,10), log(c5 ,10) from {dbname}.t1")
|
||||
|
||||
# used for sub table
|
||||
tdSql.query(f"select c1 ,log(c1 ,3) from {dbname}.ct1")
|
||||
|
@ -349,9 +265,9 @@ class TDTestCase:
|
|||
tdSql.checkData(3 , 2, 0.147315235)
|
||||
tdSql.checkData(4 , 2, None)
|
||||
|
||||
self.check_result_auto_log( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) from {dbname}.ct1")
|
||||
self.check_result_auto_log2( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c4,2), log(c5,2) from {dbname}.ct1")
|
||||
self.check_result_auto_log__10( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1,-10), log(c2,-10) ,log(c3,-10), log(c4,-10), log(c5,-10) from {dbname}.ct1")
|
||||
self.check_result_auto_log( None ,f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) from {dbname}.ct1")
|
||||
self.check_result_auto_log( 2, f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c4,2), log(c5,2) from {dbname}.ct1")
|
||||
self.check_result_auto_log( 10 , f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select log(c1,10), log(c2,10) ,log(c3,10), log(c4,10), log(c5,10) from {dbname}.ct1")
|
||||
|
||||
# nest query for log functions
|
||||
tdSql.query(f"select c1 , log(c1,3) ,log(log(c1,3),3) , log(log(log(c1,3),3),3) from {dbname}.ct1;")
|
||||
|
@ -585,15 +501,15 @@ class TDTestCase:
|
|||
tdSql.error(
|
||||
f"insert into {dbname}.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_log( f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) ,log(c6) from {dbname}.sub1_bound")
|
||||
self.check_result_auto_log2( f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c4,2), log(c5,2) ,log(c6,2) from {dbname}.sub1_bound")
|
||||
self.check_result_auto_log__10( f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1,-10), log(c2,-10) ,log(c3,-10), log(c4,-10), log(c5,-10) ,log(c6,-10) from {dbname}.sub1_bound")
|
||||
self.check_result_auto_log(None , f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1), log(c2) ,log(c3), log(c4), log(c5) ,log(c6) from {dbname}.sub1_bound")
|
||||
self.check_result_auto_log( 2 , f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c4,2), log(c5,2) ,log(c6,2) from {dbname}.sub1_bound")
|
||||
self.check_result_auto_log( 10 , f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select log(c1,10), log(c2,10) ,log(c3,10), log(c4,10), log(c5,10) ,log(c6,10) from {dbname}.sub1_bound")
|
||||
|
||||
self.check_result_auto_log2( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c3,2), log(c2,2) ,log(c1,2) from {dbname}.sub1_bound")
|
||||
self.check_result_auto_log( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select log(c1), log(c2) ,log(c3), log(c3), log(c2) ,log(c1) from {dbname}.sub1_bound")
|
||||
self.check_result_auto_log( 2 , f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select log(c1,2), log(c2,2) ,log(c3,2), log(c3,2), log(c2,2) ,log(c1,2) from {dbname}.sub1_bound")
|
||||
self.check_result_auto_log( None , f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select log(c1), log(c2) ,log(c3), log(c3), log(c2) ,log(c1) from {dbname}.sub1_bound")
|
||||
|
||||
|
||||
self.check_result_auto_log2(f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from {dbname}.sub1_bound" , f"select log(abs(c1) ,2) from {dbname}.sub1_bound" )
|
||||
self.check_result_auto_log(2 , f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from {dbname}.sub1_bound" , f"select log(abs(c1) ,2) from {dbname}.sub1_bound" )
|
||||
|
||||
# check basic elem for table per row
|
||||
tdSql.query(f"select log(abs(c1),2) ,log(abs(c2),2) , log(abs(c3),2) , log(abs(c4),2), log(abs(c5),2), log(abs(c6),2) from {dbname}.sub1_bound ")
|
||||
|
@ -647,15 +563,15 @@ class TDTestCase:
|
|||
|
||||
def support_super_table_test(self, dbname="db"):
|
||||
|
||||
self.check_result_auto_log2( f"select c5 from {dbname}.stb1 order by ts " , f"select log(c5,2) from {dbname}.stb1 order by ts" )
|
||||
self.check_result_auto_log2( f"select c5 from {dbname}.stb1 order by tbname " , f"select log(c5,2) from {dbname}.stb1 order by tbname" )
|
||||
self.check_result_auto_log2( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto_log2( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto_log( 2 , f"select c5 from {dbname}.stb1 order by ts " , f"select log(c5,2) from {dbname}.stb1 order by ts" )
|
||||
self.check_result_auto_log( 2 ,f"select c5 from {dbname}.stb1 order by tbname " , f"select log(c5,2) from {dbname}.stb1 order by tbname" )
|
||||
self.check_result_auto_log( 2 ,f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto_log( 2 , f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
|
||||
self.check_result_auto_log2( f"select t1,c5 from {dbname}.stb1 order by ts " , f"select log(t1,2), log(c5,2) from {dbname}.stb1 order by ts" )
|
||||
self.check_result_auto_log2( f"select t1,c5 from {dbname}.stb1 order by tbname " , f"select log(t1,2) ,log(c5,2) from {dbname}.stb1 order by tbname" )
|
||||
self.check_result_auto_log2( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(t1,2) ,log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto_log2( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(t1,2) , log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto_log( 2 , f"select t1,c5 from {dbname}.stb1 order by ts " , f"select log(t1,2), log(c5,2) from {dbname}.stb1 order by ts" )
|
||||
self.check_result_auto_log( 2 , f"select t1,c5 from {dbname}.stb1 order by tbname " , f"select log(t1,2) ,log(c5,2) from {dbname}.stb1 order by tbname" )
|
||||
self.check_result_auto_log( 2 , f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(t1,2) ,log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto_log( 2 ,f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select log(t1,2) , log(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
|
||||
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
||||
tdSql.prepare()
|
||||
|
|
|
@ -96,16 +96,16 @@ class TDTestCase:
|
|||
|
||||
return sqls
|
||||
|
||||
def __test_current(self):
|
||||
def __test_current(self, dbname="db"):
|
||||
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
|
||||
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"]
|
||||
tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"]
|
||||
for tb in tbname:
|
||||
self.__lower_current_check(tb)
|
||||
tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========")
|
||||
|
||||
def __test_error(self):
|
||||
def __test_error(self, dbname="db"):
|
||||
tdLog.printNoPrefix("==========err sql condition check , must return error==========")
|
||||
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"]
|
||||
tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"]
|
||||
|
||||
for tb in tbname:
|
||||
for errsql in self.__lower_err_check(tb):
|
||||
|
@ -113,22 +113,20 @@ class TDTestCase:
|
|||
tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========")
|
||||
|
||||
|
||||
def all_test(self):
|
||||
self.__test_current()
|
||||
self.__test_error()
|
||||
def all_test(self, dbname="db"):
|
||||
self.__test_current(dbname)
|
||||
self.__test_error(dbname)
|
||||
|
||||
|
||||
def __create_tb(self):
|
||||
tdSql.prepare()
|
||||
def __create_tb(self, dbname="db"):
|
||||
|
||||
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,
|
||||
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
|
||||
) tags (t1 int)
|
||||
) tags (tag1 int)
|
||||
'''
|
||||
create_ntb_sql = f'''create table t1(
|
||||
create_ntb_sql = f'''create table {dbname}.t1(
|
||||
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
|
||||
|
@ -138,78 +136,78 @@ class TDTestCase:
|
|||
tdSql.execute(create_ntb_sql)
|
||||
|
||||
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)
|
||||
for i in range(rows):
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
f'''insert into ct1 values
|
||||
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', { now_time + 8 } )
|
||||
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', { now_time + 9 } )
|
||||
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 + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
|
||||
'''
|
||||
)
|
||||
|
||||
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 * 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 + 5184000000}, {pow(2,31)-pow(2,15)}, {pow(2,63)-pow(2,30)}, 32767, 127,
|
||||
{ 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_limit-1", { now_time - 86400000}
|
||||
{ 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000}
|
||||
)
|
||||
(
|
||||
{ now_time + 2592000000 }, {pow(2,31)-pow(2,16)}, {pow(2,63)-pow(2,31)}, 32766, 126,
|
||||
{ 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_limit-2", { now_time - 172800000}
|
||||
{ 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000}
|
||||
)
|
||||
'''
|
||||
)
|
||||
|
||||
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 * 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 + 5184000000 }, { -1 * pow(2,31) + pow(2,15) }, { -1 * pow(2,63) + pow(2,30) }, -32766, -126,
|
||||
{ -1 * 3.2 * pow(10,38) }, { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_limit-1", { now_time - 86400000 }
|
||||
{ -1 * 3.2 * pow(10,38) }, { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 }
|
||||
)
|
||||
(
|
||||
{ now_time + 2592000000 }, { -1 * pow(2,31) + pow(2,16) }, { -1 * pow(2,63) + pow(2,31) }, -32767, -127,
|
||||
{ - 3.3 * pow(10,38) }, { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_limit-2", { now_time - 172800000 }
|
||||
{ - 3.3 * pow(10,38) }, { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 }
|
||||
)
|
||||
'''
|
||||
)
|
||||
|
||||
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},
|
||||
"binary_{i}", "nchar_{i}", { now_time - 1000 * i } )
|
||||
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
|
||||
'''
|
||||
tdSql.execute(insert_data)
|
||||
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 - (( 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 + 7200000 }, { pow(2,31) - pow(2,15) }, { pow(2,63) - pow(2,30) }, 32767, 127,
|
||||
{ 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 },
|
||||
"binary_limit-1", "nchar_limit-1", { now_time - 86400000 }
|
||||
"binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 }
|
||||
)
|
||||
(
|
||||
{ now_time + 3600000 } , { pow(2,31) - pow(2,16) }, { pow(2,63) - pow(2,31) }, 32766, 126,
|
||||
{ 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 },
|
||||
"binary_limit-2", "nchar_limit-2", { now_time - 172800000 }
|
||||
"binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 }
|
||||
)
|
||||
'''
|
||||
)
|
||||
|
@ -227,10 +225,7 @@ class TDTestCase:
|
|||
tdLog.printNoPrefix("==========step3:all check")
|
||||
self.all_test()
|
||||
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
|
||||
tdSql.execute("use db")
|
||||
tdSql.execute("flush database db")
|
||||
|
||||
tdLog.printNoPrefix("==========step4:after wal, all check again ")
|
||||
self.all_test()
|
||||
|
|
|
@ -23,6 +23,7 @@ CHAR_COL = [ BINARY_COL, NCHAR_COL, ]
|
|||
BOOLEAN_COL = [ BOOL_COL, ]
|
||||
TS_TYPE_COL = [ TS_COL, ]
|
||||
|
||||
DBNAME = "db"
|
||||
|
||||
class TDTestCase:
|
||||
|
||||
|
@ -120,16 +121,16 @@ class TDTestCase:
|
|||
|
||||
return sqls
|
||||
|
||||
def __test_current(self): # sourcery skip: use-itertools-product
|
||||
def __test_current(self, dbname=DBNAME): # sourcery skip: use-itertools-product
|
||||
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
|
||||
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"]
|
||||
tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"]
|
||||
for tb in tbname:
|
||||
self.__ltrim_check(tb)
|
||||
tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========")
|
||||
|
||||
def __test_error(self):
|
||||
def __test_error(self, dbname=DBNAME):
|
||||
tdLog.printNoPrefix("==========err sql condition check , must return error==========")
|
||||
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"]
|
||||
tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"]
|
||||
|
||||
for tb in tbname:
|
||||
for errsql in self.__ltrim_err_check(tb):
|
||||
|
@ -142,17 +143,16 @@ class TDTestCase:
|
|||
self.__test_error()
|
||||
|
||||
|
||||
def __create_tb(self):
|
||||
tdSql.prepare()
|
||||
def __create_tb(self, dbname=DBNAME):
|
||||
|
||||
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,
|
||||
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
|
||||
) 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,
|
||||
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
|
||||
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
|
||||
|
@ -162,29 +162,29 @@ class TDTestCase:
|
|||
tdSql.execute(create_ntb_sql)
|
||||
|
||||
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=DBNAME):
|
||||
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
|
||||
for i in range(rows):
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
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 + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
|
||||
'''
|
||||
)
|
||||
|
||||
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 * 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 )
|
||||
|
@ -200,7 +200,7 @@ class TDTestCase:
|
|||
)
|
||||
|
||||
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 * 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 )
|
||||
|
@ -216,13 +216,13 @@ class TDTestCase:
|
|||
)
|
||||
|
||||
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},
|
||||
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
|
||||
'''
|
||||
tdSql.execute(insert_data)
|
||||
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 - (( 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 )
|
||||
|
@ -251,8 +251,7 @@ class TDTestCase:
|
|||
tdLog.printNoPrefix("==========step3:all check")
|
||||
self.all_test()
|
||||
|
||||
tdDnodes.stop(1)
|
||||
tdDnodes.start(1)
|
||||
tdSql.execute("flush database db")
|
||||
|
||||
tdSql.execute("use db")
|
||||
|
||||
|
|
|
@ -307,7 +307,7 @@ class TDTestCase:
|
|||
|
||||
pass
|
||||
|
||||
def mavg_current_query(self) :
|
||||
def mavg_current_query(self, dbname="db") :
|
||||
|
||||
# table schema :ts timestamp, c1 int, c2 float, c3 timestamp, c4 binary(16), c5 double, c6 bool
|
||||
# c7 bigint, c8 smallint, c9 tinyint, c10 nchar(16)
|
||||
|
@ -325,17 +325,17 @@ class TDTestCase:
|
|||
case6 = {"col": "c9"}
|
||||
self.checkmavg(**case6)
|
||||
|
||||
# # case7~8: nested query
|
||||
# case7 = {"table_expr": f"(select c1 from {dbname}.stb1)"}
|
||||
# self.checkmavg(**case7)
|
||||
# case8 = {"table_expr": f"(select mavg(c1, 1) c1 from {dbname}.stb1 group by tbname)"}
|
||||
# case7~8: nested query
|
||||
case7 = {"table_expr": f"(select c1 from {dbname}.stb1)"}
|
||||
self.checkmavg(**case7)
|
||||
# case8 = {"table_expr": f"(select _c0, mavg(c1, 1) c1 from {dbname}.stb1 group by tbname)"}
|
||||
# self.checkmavg(**case8)
|
||||
|
||||
# case9~10: mix with tbname/ts/tag/col
|
||||
# case9 = {"alias": ", tbname"}
|
||||
# self.checkmavg(**case9)
|
||||
# case10 = {"alias": ", _c0"}
|
||||
# self.checkmavg(**case10)
|
||||
case9 = {"alias": ", tbname"}
|
||||
self.checkmavg(**case9)
|
||||
case10 = {"alias": ", _c0"}
|
||||
self.checkmavg(**case10)
|
||||
# case11 = {"alias": ", st1"}
|
||||
# self.checkmavg(**case11)
|
||||
# case12 = {"alias": ", c1"}
|
||||
|
@ -356,7 +356,7 @@ class TDTestCase:
|
|||
# case17: only support normal table join
|
||||
case17 = {
|
||||
"col": "t1.c1",
|
||||
"table_expr": "t1, t2",
|
||||
"table_expr": f"{dbname}.t1 t1, {dbname}.t2 t2",
|
||||
"condition": "where t1.ts=t2.ts"
|
||||
}
|
||||
self.checkmavg(**case17)
|
||||
|
@ -367,14 +367,14 @@ class TDTestCase:
|
|||
# }
|
||||
# self.checkmavg(**case19)
|
||||
|
||||
# case20~21: with order by
|
||||
# # case20~21: with order by
|
||||
# case20 = {"condition": "order by ts"}
|
||||
# self.checkmavg(**case20)
|
||||
#case21 = {
|
||||
# "table_expr": f"{dbname}.stb1",
|
||||
# "condition": "group by tbname order by tbname"
|
||||
#}
|
||||
#self.checkmavg(**case21)
|
||||
case21 = {
|
||||
"table_expr": f"{dbname}.stb1",
|
||||
"condition": "group by tbname order by tbname"
|
||||
}
|
||||
self.checkmavg(**case21)
|
||||
|
||||
# # case22: with union
|
||||
# case22 = {
|
||||
|
@ -398,7 +398,7 @@ class TDTestCase:
|
|||
|
||||
pass
|
||||
|
||||
def mavg_error_query(self) -> None :
|
||||
def mavg_error_query(self, dbname="db") -> None :
|
||||
# unusual test
|
||||
|
||||
# form test
|
||||
|
@ -419,9 +419,9 @@ class TDTestCase:
|
|||
err8 = {"table_expr": ""}
|
||||
self.checkmavg(**err8) # no table_expr
|
||||
|
||||
# err9 = {"col": "st1"}
|
||||
err9 = {"col": "st1"}
|
||||
# self.checkmavg(**err9) # col: tag
|
||||
# err10 = {"col": 1}
|
||||
err10 = {"col": 1}
|
||||
# self.checkmavg(**err10) # col: value
|
||||
err11 = {"col": "NULL"}
|
||||
self.checkmavg(**err11) # col: NULL
|
||||
|
@ -496,7 +496,7 @@ class TDTestCase:
|
|||
# "condition": "where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts"
|
||||
# }
|
||||
# self.checkmavg(**err44) # stb join
|
||||
tdSql.query("select mavg( stb1.c1 , 1 ) from stb1, stb2 where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts;")
|
||||
tdSql.query(f"select mavg( stb1.c1 , 1 ) from {dbname}.stb1 stb1, {dbname}.stb2 stb2 where stb1.ts=stb2.ts and stb1.st1=stb2.st2 order by stb1.ts;")
|
||||
err45 = {
|
||||
"condition": "where ts>0 and ts < now interval(1h) fill(next)"
|
||||
}
|
||||
|
|
|
@ -5,10 +5,7 @@ import numpy as np
|
|||
|
||||
|
||||
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):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor())
|
||||
|
@ -17,60 +14,80 @@ class TDTestCase:
|
|||
self.ts = 1537146000000
|
||||
self.binary_str = 'taosdata'
|
||||
self.nchar_str = '涛思数据'
|
||||
def max_check_stb_and_tb_base(self):
|
||||
def max_check_stb_and_tb_base(self, dbname="db"):
|
||||
tdSql.prepare()
|
||||
intData = []
|
||||
floatData = []
|
||||
tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
|
||||
tdSql.execute(f'''create table {dbname}.stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
|
||||
col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) 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')")
|
||||
for i in range(self.rowNum):
|
||||
tdSql.execute(f"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')"
|
||||
tdSql.execute(f"insert into {dbname}.stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')"
|
||||
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1))
|
||||
intData.append(i + 1)
|
||||
floatData.append(i + 0.1)
|
||||
for i in ['ts','col11','col12','col13']:
|
||||
for j in ['db.stb','stb','db.stb_1','stb_1']:
|
||||
tdSql.error(f'select max({i} from {j} )')
|
||||
for i in ['col11','col12','col13']:
|
||||
for j in ['stb','stb_1']:
|
||||
tdSql.error(f'select max({i} from {dbname}.{j} )')
|
||||
|
||||
for i in range(1,11):
|
||||
for j in ['db.stb','stb','db.stb_1','stb_1']:
|
||||
tdSql.query(f"select max(col{i}) from {j}")
|
||||
for j in ['stb', 'stb_1']:
|
||||
tdSql.query(f"select max(col{i}) from {dbname}.{j}")
|
||||
if i<9:
|
||||
tdSql.checkData(0, 0, np.max(intData))
|
||||
elif i>=9:
|
||||
tdSql.checkData(0, 0, np.max(floatData))
|
||||
tdSql.query("select max(col1) from stb_1 where col2<=5")
|
||||
tdSql.checkData(0,0,5)
|
||||
tdSql.query("select max(col1) from stb where col2<=5")
|
||||
tdSql.checkData(0,0,5)
|
||||
tdSql.execute('drop database db')
|
||||
|
||||
def max_check_ntb_base(self):
|
||||
tdSql.query(f"select max(now()) from {dbname}.stb_1")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.query(f"select last(ts) from {dbname}.stb_1")
|
||||
lastTs = tdSql.getData(0, 0)
|
||||
tdSql.query(f"select max(ts) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, lastTs)
|
||||
|
||||
tdSql.query(f"select last(ts) from {dbname}.stb")
|
||||
lastTs = tdSql.getData(0, 0)
|
||||
tdSql.query(f"select max(ts) from {dbname}.stb")
|
||||
tdSql.checkData(0, 0, lastTs)
|
||||
|
||||
tdSql.query(f"select max(col1) from {dbname}.stb_1 where col2<=5")
|
||||
tdSql.checkData(0,0,5)
|
||||
tdSql.query(f"select max(col1) from {dbname}.stb where col2<=5")
|
||||
tdSql.checkData(0,0,5)
|
||||
|
||||
def max_check_ntb_base(self, dbname="db"):
|
||||
tdSql.prepare()
|
||||
intData = []
|
||||
floatData = []
|
||||
tdSql.execute('''create table ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
|
||||
tdSql.execute(f'''create table {dbname}.ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
|
||||
col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20))''')
|
||||
for i in range(self.rowNum):
|
||||
tdSql.execute(f"insert into ntb values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')"
|
||||
tdSql.execute(f"insert into {dbname}.ntb values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')"
|
||||
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1))
|
||||
intData.append(i + 1)
|
||||
floatData.append(i + 0.1)
|
||||
for i in ['ts','col11','col12','col13']:
|
||||
for j in ['db.ntb','ntb']:
|
||||
tdSql.error(f'select max({i} from {j} )')
|
||||
for i in ['col11','col12','col13']:
|
||||
for j in ['ntb']:
|
||||
tdSql.error(f'select max({i} from {dbname}.{j} )')
|
||||
for i in range(1,11):
|
||||
for j in ['db.ntb','ntb']:
|
||||
tdSql.query(f"select max(col{i}) from {j}")
|
||||
for j in ['ntb']:
|
||||
tdSql.query(f"select max(col{i}) from {dbname}.{j}")
|
||||
if i<9:
|
||||
tdSql.checkData(0, 0, np.max(intData))
|
||||
elif i>=9:
|
||||
tdSql.checkData(0, 0, np.max(floatData))
|
||||
tdSql.query("select max(col1) from ntb where col2<=5")
|
||||
tdSql.checkData(0,0,5)
|
||||
tdSql.execute('drop database db')
|
||||
|
||||
tdSql.query(f"select max(now()) from {dbname}.ntb")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.query(f"select last(ts) from {dbname}.ntb")
|
||||
lastTs = tdSql.getData(0, 0)
|
||||
tdSql.query(f"select max(ts) from {dbname}.ntb")
|
||||
tdSql.checkData(0, 0, lastTs)
|
||||
|
||||
tdSql.query(f"select max(col1) from {dbname}.ntb where col2<=5")
|
||||
tdSql.checkData(0,0,5)
|
||||
|
||||
def check_max_functions(self, tbname , col_name):
|
||||
|
||||
|
@ -90,55 +107,55 @@ class TDTestCase:
|
|||
tdLog.info(" max function work as expected, sql : %s "% max_sql)
|
||||
|
||||
|
||||
def support_distributed_aggregate(self):
|
||||
def support_distributed_aggregate(self, dbname="testdb"):
|
||||
|
||||
# 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(" use testdb ")
|
||||
tdSql.execute(f"create database if not exists {dbname} keep 3650 duration 1000 vgroups 5")
|
||||
tdSql.execute(f"use {dbname} ")
|
||||
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)
|
||||
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
|
||||
f'''
|
||||
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)
|
||||
'''
|
||||
)
|
||||
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):
|
||||
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(
|
||||
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):
|
||||
if i ==1 or i == 4:
|
||||
continue
|
||||
else:
|
||||
tbname = "ct"+f'{i}'
|
||||
tbname = f"{dbname}.ct{i}"
|
||||
for j in range(9):
|
||||
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 )"
|
||||
)
|
||||
tdSql.execute("insert into 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("insert into 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()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
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(f"insert into {dbname}.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()+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("insert into 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()-810d, 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(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
|
||||
f'''insert into {dbname}.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 )
|
||||
|
@ -157,7 +174,7 @@ class TDTestCase:
|
|||
tdLog.info(" prepare data for distributed_aggregate done! ")
|
||||
|
||||
# get vgroup_ids of all
|
||||
tdSql.query("show vgroups ")
|
||||
tdSql.query(f"show {dbname}.vgroups ")
|
||||
vgroups = tdSql.queryResult
|
||||
|
||||
vnode_tables={}
|
||||
|
@ -167,7 +184,7 @@ class TDTestCase:
|
|||
|
||||
|
||||
# check sub_table of per vnode ,make sure sub_table has been distributed
|
||||
tdSql.query("select * from information_schema.ins_tables where db_name = 'testdb' and table_name like 'ct%'")
|
||||
tdSql.query(f"select * from information_schema.ins_tables where db_name = '{dbname}' and table_name like 'ct%'")
|
||||
table_names = tdSql.queryResult
|
||||
tablenames = []
|
||||
for table_name in table_names:
|
||||
|
@ -182,13 +199,13 @@ class TDTestCase:
|
|||
|
||||
# check max function work status
|
||||
|
||||
tdSql.query("show tables like 'ct%'")
|
||||
tdSql.query(f"show {dbname}.tables like 'ct%'")
|
||||
table_names = tdSql.queryResult
|
||||
tablenames = []
|
||||
for table_name in table_names:
|
||||
tablenames.append(table_name[0])
|
||||
|
||||
tdSql.query("desc stb1")
|
||||
tdSql.query(f"desc {dbname}.stb1")
|
||||
col_names = tdSql.queryResult
|
||||
|
||||
colnames = []
|
||||
|
@ -198,11 +215,7 @@ class TDTestCase:
|
|||
|
||||
for tablename in tablenames:
|
||||
for colname in colnames:
|
||||
self.check_max_functions(tablename,colname)
|
||||
|
||||
# max function with basic filter
|
||||
print(vnode_tables)
|
||||
|
||||
self.check_max_functions(f"{dbname}.{tablename}", colname)
|
||||
|
||||
def run(self):
|
||||
|
||||
|
|
|
@ -12,16 +12,15 @@ class TDTestCase:
|
|||
self.tb_nums = 10
|
||||
self.ts = 1537146000000
|
||||
|
||||
def prepare_datas(self, stb_name , tb_nums , row_nums ):
|
||||
tdSql.execute(" use db ")
|
||||
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,\
|
||||
def prepare_datas(self, stb_name , tb_nums , row_nums, dbname="db" ):
|
||||
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)\
|
||||
, t10 nchar(36) , t11 int unsigned , t12 bigint unsigned ,t13 smallint unsigned , t14 tinyint unsigned ) ")
|
||||
|
||||
for i in range(tb_nums):
|
||||
tbname = f"sub_{stb_name}_{i}"
|
||||
tbname = f"{dbname}.sub_{stb_name}_{i}"
|
||||
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):
|
||||
ts = self.ts + row*1000
|
||||
|
@ -31,191 +30,192 @@ class TDTestCase:
|
|||
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 )")
|
||||
|
||||
def basic_query(self):
|
||||
tdSql.query("select count(*) from stb")
|
||||
def basic_query(self, dbname="db"):
|
||||
tdSql.query(f"select count(*) from {dbname}.stb")
|
||||
tdSql.checkData(0,0,(self.row_nums + 5 )*self.tb_nums)
|
||||
tdSql.query("select max(c1) from stb")
|
||||
tdSql.query(f"select max(c1) from {dbname}.stb")
|
||||
tdSql.checkData(0,0,(self.row_nums -1))
|
||||
tdSql.query(" select tbname , max(c1) from stb partition by tbname ")
|
||||
tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by tbname ")
|
||||
tdSql.checkRows(self.tb_nums)
|
||||
tdSql.query(" select max(c1) from stb group by t1 order by t1 ")
|
||||
tdSql.query(f"select max(c1) from {dbname}.stb group by t1 order by t1 ")
|
||||
tdSql.checkRows(self.tb_nums)
|
||||
tdSql.query(" select max(c1) from stb group by c1 order by t1 ")
|
||||
tdSql.query(" select max(t2) from stb group by c1 order by t1 ")
|
||||
tdSql.query(" select max(c1) from stb group by tbname order by tbname ")
|
||||
tdSql.query(f"select max(c1) from {dbname}.stb group by c1 order by t1 ")
|
||||
tdSql.query(f"select max(t2) from {dbname}.stb group by c1 order by t1 ")
|
||||
tdSql.query(f"select max(c1) from {dbname}.stb group by tbname order by tbname ")
|
||||
tdSql.checkRows(self.tb_nums)
|
||||
# bug need fix
|
||||
tdSql.query(" select max(t2) from stb group by t2 order by t2 ")
|
||||
tdSql.query(f"select max(t2) from {dbname}.stb group by t2 order by t2 ")
|
||||
tdSql.checkRows(self.tb_nums)
|
||||
tdSql.query(" select max(c1) from stb group by c1 order by c1 ")
|
||||
tdSql.query(f"select max(c1) from {dbname}.stb group by c1 order by c1 ")
|
||||
tdSql.checkRows(self.row_nums+1)
|
||||
|
||||
tdSql.query(" select c1 , max(c1) from stb group by c1 order by c1 ")
|
||||
tdSql.query(f"select c1 , max(c1) from {dbname}.stb group by c1 order by c1 ")
|
||||
tdSql.checkRows(self.row_nums+1)
|
||||
|
||||
# support selective functions
|
||||
tdSql.query(" select c1 ,c2 ,c3 , max(c1) ,c4 ,c5 ,t11 from stb group by c1 order by c1 desc ")
|
||||
tdSql.query(f"select c1 ,c2 ,c3 , max(c1) ,c4 ,c5 ,t11 from {dbname}.stb group by c1 order by c1 desc ")
|
||||
tdSql.checkRows(self.row_nums+1)
|
||||
|
||||
tdSql.query(" select c1, tbname , max(c1) ,c4 ,c5 ,t11 from stb group by c1 order by c1 desc ")
|
||||
tdSql.query(f"select c1, tbname , max(c1) ,c4 ,c5 ,t11 from {dbname}.stb group by c1 order by c1 desc ")
|
||||
tdSql.checkRows(self.row_nums+1)
|
||||
|
||||
# bug need fix
|
||||
# tdSql.query(" select tbname , max(c1) from sub_stb_1 where c1 is null group by c1 order by c1 desc ")
|
||||
# tdSql.checkRows(1)
|
||||
# tdSql.checkData(0,0,"sub_stb_1")
|
||||
tdSql.query(f"select tbname , max(c1) from {dbname}.sub_stb_1 where c1 is null group by c1 order by c1 desc ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,"sub_stb_1")
|
||||
|
||||
tdSql.query("select max(c1) ,c2 ,t2,tbname from stb group by abs(c1) order by abs(c1)")
|
||||
tdSql.query(f"select max(c1) ,c2 ,t2,tbname from {dbname}.stb group by abs(c1) order by abs(c1)")
|
||||
tdSql.checkRows(self.row_nums+1)
|
||||
tdSql.query("select abs(c1+c3), count(c1+c3) ,max(c1+t2) from stb group by abs(c1+c3) order by abs(c1+c3)")
|
||||
tdSql.query(f"select abs(c1+c3), count(c1+c3) ,max(c1+t2) from {dbname}.stb group by abs(c1+c3) order by abs(c1+c3)")
|
||||
tdSql.checkRows(self.row_nums+1)
|
||||
tdSql.query("select max(c1+c3)+min(c2) ,abs(c1) from stb group by abs(c1) order by abs(c1)")
|
||||
tdSql.query(f"select max(c1+c3)+min(c2) ,abs(c1) from {dbname}.stb group by abs(c1) order by abs(c1)")
|
||||
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("select count(c1+c3)+max(c2) ,abs(c1) from stb group by abs(c1) order by abs(c1)+c2")
|
||||
tdSql.query("select abs(c1+c3)+abs(c2) , count(c1+c3)+max(c2) from stb group by abs(c1+c3)+abs(c2) order by abs(c1+c3)+abs(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(f"select count(c1+c3)+max(c2) ,abs(c1) from {dbname}.stb group by abs(c1) order by abs(c1)+c2")
|
||||
tdSql.query(f"select abs(c1+c3)+abs(c2) , count(c1+c3)+max(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.query(" select max(c1) , max(t2) from stb where abs(c1+t2)=1 partition by tbname ")
|
||||
tdSql.query(f"select max(c1) , max(t2) from {dbname}.stb where abs(c1+t2)=1 partition by tbname ")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.query(" select max(c1) from stb where abs(c1+t2)=1 partition by tbname ")
|
||||
tdSql.query(f"select max(c1) from {dbname}.stb where abs(c1+t2)=1 partition by tbname ")
|
||||
tdSql.checkRows(2)
|
||||
|
||||
tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname ")
|
||||
tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by tbname order by tbname ")
|
||||
tdSql.checkRows(self.tb_nums)
|
||||
tdSql.checkData(0,1,self.row_nums-1)
|
||||
|
||||
tdSql.query("select tbname , max(c2) from stb partition by t1 order by t1")
|
||||
tdSql.query("select tbname , max(t2) from stb partition by t1 order by t1")
|
||||
tdSql.query("select tbname , max(t2) from stb partition by t2 order by t2")
|
||||
tdSql.query(f"select tbname , max(c2) from {dbname}.stb partition by t1 order by t1")
|
||||
tdSql.query(f"select tbname , max(t2) from {dbname}.stb partition by t1 order by t1")
|
||||
tdSql.query(f"select tbname , max(t2) from {dbname}.stb partition by t2 order by t2")
|
||||
|
||||
# # bug need fix
|
||||
tdSql.query("select t2 , max(t2) from stb partition by t2 order by t2")
|
||||
tdSql.query(f"select t2 , max(t2) from {dbname}.stb partition by t2 order by t2")
|
||||
tdSql.checkRows(self.tb_nums)
|
||||
|
||||
tdSql.query("select tbname , max(c1) from stb partition by tbname order by tbname")
|
||||
tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by tbname order by tbname")
|
||||
tdSql.checkRows(self.tb_nums)
|
||||
tdSql.checkData(0,1,self.row_nums-1)
|
||||
|
||||
|
||||
tdSql.query("select tbname , max(c1) from stb partition by t2 order by t2")
|
||||
tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by t2 order by t2")
|
||||
|
||||
tdSql.query("select c2, max(c1) from stb partition by c2 order by c2 desc")
|
||||
tdSql.query(f"select c2, max(c1) from {dbname}.stb partition by c2 order by c2 desc")
|
||||
tdSql.checkRows(self.tb_nums+1)
|
||||
tdSql.checkData(0,1,self.row_nums-1)
|
||||
|
||||
tdSql.query("select tbname , max(c1) from stb partition by c1 order by c2")
|
||||
tdSql.query(f"select tbname , max(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.query("select max(c1) , count(t2) from stb partition by c2 ")
|
||||
tdSql.query(f"select max(c1) , count(t2) from {dbname}.stb partition by c2 ")
|
||||
tdSql.checkRows(self.row_nums+1)
|
||||
tdSql.checkData(0,1,self.row_nums)
|
||||
|
||||
tdSql.query("select count(c1) , max(t2) ,c2 from stb partition by c2 order by c2")
|
||||
tdSql.query(f"select count(c1) , max(t2) ,c2 from {dbname}.stb partition by c2 order by c2")
|
||||
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.checkCols(4)
|
||||
|
||||
tdSql.query("select count(c1) , max(t2) ,t1 from stb partition by t1 order by t1")
|
||||
tdSql.query(f"select count(c1) , max(t2) ,t1 from {dbname}.stb partition by t1 order by t1")
|
||||
tdSql.checkRows(self.tb_nums)
|
||||
tdSql.checkData(0,0,self.row_nums)
|
||||
|
||||
# bug need fix
|
||||
tdSql.query("select count(c1) , max(t2) ,abs(c1) from stb partition by abs(c1) order by abs(c1)")
|
||||
tdSql.query(f"select count(c1) , max(t2) ,abs(c1) from {dbname}.stb partition by abs(c1) order by abs(c1)")
|
||||
tdSql.checkRows(self.row_nums+1)
|
||||
|
||||
|
||||
tdSql.query("select max(ceil(c2)) , max(floor(t2)) ,max(floor(c2)) from stb partition by abs(c2) order by abs(c2)")
|
||||
tdSql.query(f"select max(ceil(c2)) , max(floor(t2)) ,max(floor(c2)) from {dbname}.stb partition by abs(c2) order by abs(c2)")
|
||||
tdSql.checkRows(self.row_nums+1)
|
||||
|
||||
|
||||
tdSql.query("select max(ceil(c1-2)) , max(floor(t2+1)) ,max(c2-c1) from stb partition by abs(floor(c1)) order by abs(floor(c1))")
|
||||
tdSql.query(f"select max(ceil(c1-2)) , max(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.query("select tbname , max(c1) ,c1 from stb partition by tbname order by tbname")
|
||||
tdSql.query(f"select tbname , max(c1) ,c1 from {dbname}.stb partition by tbname order by tbname")
|
||||
tdSql.checkRows(self.tb_nums)
|
||||
tdSql.checkData(0,0,'sub_stb_0')
|
||||
tdSql.checkData(0,1,9)
|
||||
tdSql.checkData(0,2,9)
|
||||
|
||||
tdSql.query("select tbname ,top(c1,1) ,c1 from stb partition by tbname order by tbname")
|
||||
tdSql.query(f"select tbname ,top(c1,1) ,c1 from {dbname}.stb partition by tbname order by tbname")
|
||||
tdSql.checkRows(self.tb_nums)
|
||||
|
||||
tdSql.query(" select c1 , sample(c1,2) from stb partition by tbname order by tbname ")
|
||||
tdSql.query(f"select c1 , sample(c1,2) from {dbname}.stb partition by tbname order by tbname ")
|
||||
tdSql.checkRows(self.tb_nums*2)
|
||||
|
||||
|
||||
# interval
|
||||
tdSql.query("select max(c1) from stb interval(2s) sliding(1s)")
|
||||
tdSql.query(f"select max(c1) from {dbname}.stb interval(2s) sliding(1s)")
|
||||
|
||||
# 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 , max(c1) from stb partition by tbname interval(10s)")
|
||||
tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by tbname interval(10s)")
|
||||
tdSql.checkRows(self.row_nums*2)
|
||||
|
||||
tdSql.query("select unique(c1) from stb partition by tbname order by tbname")
|
||||
tdSql.query(f"select unique(c1) from {dbname}.stb partition by tbname order by tbname")
|
||||
|
||||
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,1,self.row_nums)
|
||||
|
||||
tdSql.query("select c1 , mavg(c1 ,2 ) from stb partition by c1")
|
||||
tdSql.query(f"select c1 , mavg(c1 ,2 ) from {dbname}.stb partition by c1")
|
||||
tdSql.checkRows(90)
|
||||
|
||||
tdSql.query("select c1 , diff(c1 , 0) from stb partition by c1")
|
||||
tdSql.query(f"select c1 , diff(c1 , 0) from {dbname}.stb partition by c1")
|
||||
tdSql.checkRows(90)
|
||||
|
||||
tdSql.query("select c1 , csum(c1) from stb partition by c1")
|
||||
tdSql.query(f"select c1 , csum(c1) from {dbname}.stb partition by c1")
|
||||
tdSql.checkRows(100)
|
||||
|
||||
tdSql.query("select c1 , sample(c1,2) from stb partition by c1 order by c1")
|
||||
tdSql.query(f"select c1 , sample(c1,2) from {dbname}.stb partition by c1 order by c1")
|
||||
tdSql.checkRows(21)
|
||||
# bug need fix
|
||||
# tdSql.checkData(0,1,None)
|
||||
tdSql.checkData(0,1,None)
|
||||
|
||||
tdSql.query("select c1 , twa(c1) from stb partition by c1 order by c1")
|
||||
tdSql.query(f"select c1 , twa(c1) from {dbname}.stb partition by c1 order by c1")
|
||||
tdSql.checkRows(11)
|
||||
tdSql.checkData(0,1,None)
|
||||
|
||||
tdSql.query("select c1 , irate(c1) from stb partition by c1 order by c1")
|
||||
tdSql.query(f"select c1 , irate(c1) from {dbname}.stb partition by c1 order by c1")
|
||||
tdSql.checkRows(11)
|
||||
tdSql.checkData(0,1,None)
|
||||
|
||||
tdSql.query("select c1 , DERIVATIVE(c1,2,1) from stb partition by c1 order by c1")
|
||||
tdSql.query(f"select c1 , DERIVATIVE(c1,2,1) from {dbname}.stb partition by c1 order by c1")
|
||||
tdSql.checkRows(90)
|
||||
# bug need fix
|
||||
tdSql.checkData(0,1,None)
|
||||
|
||||
|
||||
tdSql.query(" select tbname , max(c1) from stb partition by tbname order by tbname slimit 5 soffset 0 ")
|
||||
tdSql.query(f"select tbname , max(c1) from {dbname}.stb partition by tbname order by tbname slimit 5 soffset 0 ")
|
||||
tdSql.checkRows(10)
|
||||
|
||||
tdSql.query(" select tbname , max(c1) from sub_stb_1 partition by tbname interval(10s) sliding(5s) ")
|
||||
tdSql.query(f"select tbname , max(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}+1000 interval(50s) sliding(30s)')
|
||||
tdSql.query(f'select tbname , max(c1) from stb where ts>={self.ts} and ts < {self.ts}+1000 interval(50s) sliding(30s)')
|
||||
tdSql.query(f'select max(c1) from {dbname}.stb where ts>={self.ts} and ts < {self.ts}+1000 interval(50s) sliding(30s)')
|
||||
tdSql.query(f'select tbname , max(c1) from {dbname}.stb where ts>={self.ts} and ts < {self.ts}+1000 interval(50s) sliding(30s)')
|
||||
|
||||
|
||||
def run(self):
|
||||
dbname = "db"
|
||||
tdSql.prepare()
|
||||
self.prepare_datas("stb",self.tb_nums,self.row_nums)
|
||||
self.basic_query()
|
||||
|
||||
# # 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 ")
|
||||
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 ")
|
||||
|
||||
|
||||
def stop(self):
|
||||
|
|
|
@ -14,198 +14,159 @@ class TDTestCase:
|
|||
self.ts = 1537146000000
|
||||
|
||||
def run(self):
|
||||
dbname = "db"
|
||||
tdSql.prepare()
|
||||
|
||||
intData = []
|
||||
floatData = []
|
||||
|
||||
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))''')
|
||||
tdSql.execute("create table stb_1 using stb tags('beijing')")
|
||||
tdSql.execute('''create table ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
|
||||
tdSql.execute(f"create table {dbname}.stb_1 using {dbname}.stb tags('beijing')")
|
||||
tdSql.execute(f'''create table {dbname}.ntb(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)''')
|
||||
for i in range(self.rowNum):
|
||||
tdSql.execute("insert into ntb values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
|
||||
tdSql.execute(f"insert into {dbname}.ntb 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))
|
||||
intData.append(i + 1)
|
||||
floatData.append(i + 0.1)
|
||||
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))
|
||||
intData.append(i + 1)
|
||||
floatData.append(i + 0.1)
|
||||
|
||||
# max verifacation
|
||||
tdSql.error("select min(ts) from stb_1")
|
||||
tdSql.error("select min(ts) from db.stb_1")
|
||||
tdSql.error("select min(col7) from stb_1")
|
||||
tdSql.error("select min(col7) from db.stb_1")
|
||||
tdSql.error("select min(col8) from stb_1")
|
||||
tdSql.error("select min(col8) from db.stb_1")
|
||||
tdSql.error("select min(col9) from stb_1")
|
||||
tdSql.error("select min(col9) from db.stb_1")
|
||||
# tdSql.error("select min(a) from stb_1")
|
||||
# tdSql.error("select min(1) from stb_1")
|
||||
tdSql.error("select min(now()) from stb_1")
|
||||
tdSql.error("select min(count(c1),count(c2)) from stb_1")
|
||||
tdSql.error(f"select min(col7) from {dbname}.stb_1")
|
||||
tdSql.error(f"select min(col8) from {dbname}.stb_1")
|
||||
tdSql.error(f"select min(col9) from {dbname}.stb_1")
|
||||
tdSql.error(f"select min(a) from {dbname}.stb_1")
|
||||
tdSql.query(f"select min(1) from {dbname}.stb_1")
|
||||
tdSql.error(f"select min(count(c1),count(c2)) from {dbname}.stb_1")
|
||||
|
||||
tdSql.query("select min(col1) from stb_1")
|
||||
tdSql.query(f"select min(col1) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col1) from db.stb_1")
|
||||
tdSql.query(f"select min(col2) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col2) from stb_1")
|
||||
tdSql.query(f"select min(col3) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col2) from db.stb_1")
|
||||
tdSql.query(f"select min(col4) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col3) from stb_1")
|
||||
tdSql.query(f"select min(col11) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col3) from db.stb_1")
|
||||
tdSql.query(f"select min(col12) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col4) from stb_1")
|
||||
tdSql.query(f"select min(col13) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col4) from db.stb_1")
|
||||
tdSql.query(f"select min(col14) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col11) from stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col11) from db.stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col12) from stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col12) from db.stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col13) from stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col13) from db.stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col14) from stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col14) from db.stb_1")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col5) from stb_1")
|
||||
tdSql.query(f"select min(col5) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, np.min(floatData))
|
||||
tdSql.query("select min(col5) from db.stb_1")
|
||||
tdSql.query(f"select min(col6) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, np.min(floatData))
|
||||
tdSql.query("select min(col6) from stb_1")
|
||||
tdSql.checkData(0, 0, np.min(floatData))
|
||||
tdSql.query("select min(col6) from db.stb_1")
|
||||
tdSql.checkData(0, 0, np.min(floatData))
|
||||
tdSql.query("select min(col1) from stb_1 where col2>=5")
|
||||
tdSql.query(f"select min(col1) from {dbname}.stb_1 where col2>=5")
|
||||
tdSql.checkData(0,0,5)
|
||||
|
||||
tdSql.query(f"select min(now()) from {dbname}.stb_1")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.error("select min(ts) from stb_1")
|
||||
tdSql.error("select min(ts) from db.stb_1")
|
||||
tdSql.error("select min(col7) from stb_1")
|
||||
tdSql.error("select min(col7) from db.stb_1")
|
||||
tdSql.error("select min(col8) from stb_1")
|
||||
tdSql.error("select min(col8) from db.stb_1")
|
||||
tdSql.error("select min(col9) from stb_1")
|
||||
tdSql.error("select min(col9) from db.stb_1")
|
||||
# tdSql.error("select min(a) from stb_1")
|
||||
# tdSql.error("select min(1) from stb_1")
|
||||
tdSql.error("select min(now()) from stb_1")
|
||||
tdSql.error("select min(count(c1),count(c2)) from stb_1")
|
||||
tdSql.query(f"select first(ts) from {dbname}.stb_1")
|
||||
firstTs = tdSql.getData(0, 0)
|
||||
tdSql.query(f"select min(ts) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, firstTs)
|
||||
|
||||
tdSql.query("select min(col1) from stb")
|
||||
tdSql.query(f"select first(ts) from {dbname}.stb_1")
|
||||
firstTs = tdSql.getData(0, 0)
|
||||
tdSql.query(f"select min(ts) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, firstTs)
|
||||
|
||||
|
||||
tdSql.error(f"select min(col7) from {dbname}.stb_1")
|
||||
tdSql.error(f"select min(col8) from {dbname}.stb_1")
|
||||
tdSql.error(f"select min(col9) from {dbname}.stb_1")
|
||||
tdSql.error(f"select min(a) from {dbname}.stb_1")
|
||||
tdSql.query(f"select min(1) from {dbname}.stb_1")
|
||||
tdSql.error(f"select min(count(c1),count(c2)) from {dbname}.stb_1")
|
||||
|
||||
tdSql.query(f"select min(col1) from {dbname}.stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col1) from db.stb")
|
||||
tdSql.query(f"select min(col2) from {dbname}.stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col2) from stb")
|
||||
tdSql.query(f"select min(col3) from {dbname}.stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col2) from db.stb")
|
||||
tdSql.query(f"select min(col4) from {dbname}.stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col3) from stb")
|
||||
tdSql.query(f"select min(col11) from {dbname}.stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col3) from db.stb")
|
||||
tdSql.query(f"select min(col12) from {dbname}.stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col4) from stb")
|
||||
tdSql.query(f"select min(col13) from {dbname}.stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col4) from db.stb")
|
||||
tdSql.query(f"select min(col14) from {dbname}.stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col11) from stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col11) from db.stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col12) from stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col12) from db.stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col13) from stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col13) from db.stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col14) from stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col14) from db.stb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col5) from stb")
|
||||
tdSql.query(f"select min(col5) from {dbname}.stb")
|
||||
tdSql.checkData(0, 0, np.min(floatData))
|
||||
tdSql.query("select min(col5) from db.stb")
|
||||
tdSql.query(f"select min(col6) from {dbname}.stb")
|
||||
tdSql.checkData(0, 0, np.min(floatData))
|
||||
tdSql.query("select min(col6) from stb")
|
||||
tdSql.checkData(0, 0, np.min(floatData))
|
||||
tdSql.query("select min(col6) from db.stb")
|
||||
tdSql.checkData(0, 0, np.min(floatData))
|
||||
tdSql.query("select min(col1) from stb where col2>=5")
|
||||
tdSql.query(f"select min(col1) from {dbname}.stb where col2>=5")
|
||||
tdSql.checkData(0,0,5)
|
||||
|
||||
tdSql.query(f"select min(now()) from {dbname}.stb_1")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.error("select min(ts) from ntb")
|
||||
tdSql.error("select min(ts) from db.ntb")
|
||||
tdSql.error("select min(col7) from ntb")
|
||||
tdSql.error("select min(col7) from db.ntb")
|
||||
tdSql.error("select min(col8) from ntb")
|
||||
tdSql.error("select min(col8) from db.ntb")
|
||||
tdSql.error("select min(col9) from ntb")
|
||||
tdSql.error("select min(col9) from db.ntb")
|
||||
# tdSql.error("select min(a) from stb_1")
|
||||
# tdSql.error("select min(1) from stb_1")
|
||||
tdSql.error("select min(now()) from ntb")
|
||||
tdSql.error("select min(count(c1),count(c2)) from ntb")
|
||||
tdSql.query(f"select first(ts) from {dbname}.stb_1")
|
||||
firstTs = tdSql.getData(0, 0)
|
||||
tdSql.query(f"select min(ts) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, firstTs)
|
||||
|
||||
tdSql.query("select min(col1) from ntb")
|
||||
tdSql.query(f"select first(ts) from {dbname}.stb_1")
|
||||
firstTs = tdSql.getData(0, 0)
|
||||
tdSql.query(f"select min(ts) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, firstTs)
|
||||
|
||||
tdSql.error(f"select min(col7) from {dbname}.ntb")
|
||||
tdSql.error(f"select min(col8) from {dbname}.ntb")
|
||||
tdSql.error(f"select min(col9) from {dbname}.ntb")
|
||||
tdSql.error(f"select min(a) from {dbname}.ntb")
|
||||
tdSql.query(f"select min(1) from {dbname}.ntb")
|
||||
tdSql.error(f"select min(count(c1),count(c2)) from {dbname}.ntb")
|
||||
|
||||
tdSql.query(f"select min(col1) from {dbname}.ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col1) from db.ntb")
|
||||
tdSql.query(f"select min(col2) from {dbname}.ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col2) from ntb")
|
||||
tdSql.query(f"select min(col3) from {dbname}.ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col2) from db.ntb")
|
||||
tdSql.query(f"select min(col4) from {dbname}.ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col3) from ntb")
|
||||
tdSql.query(f"select min(col11) from {dbname}.ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col3) from db.ntb")
|
||||
tdSql.query(f"select min(col12) from {dbname}.ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col4) from ntb")
|
||||
tdSql.query(f"select min(col13) from {dbname}.ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col4) from db.ntb")
|
||||
tdSql.query(f"select min(col14) from {dbname}.ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col11) from ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col11) from db.ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col12) from ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col12) from db.ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col13) from ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col13) from db.ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col14) from ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col14) from db.ntb")
|
||||
tdSql.checkData(0, 0, np.min(intData))
|
||||
tdSql.query("select min(col5) from ntb")
|
||||
tdSql.query(f"select min(col5) from {dbname}.ntb")
|
||||
tdSql.checkData(0, 0, np.min(floatData))
|
||||
tdSql.query("select min(col5) from db.ntb")
|
||||
tdSql.query(f"select min(col6) from {dbname}.ntb")
|
||||
tdSql.checkData(0, 0, np.min(floatData))
|
||||
tdSql.query("select min(col6) from ntb")
|
||||
tdSql.checkData(0, 0, np.min(floatData))
|
||||
tdSql.query("select min(col6) from db.ntb")
|
||||
tdSql.checkData(0, 0, np.min(floatData))
|
||||
tdSql.query("select min(col1) from ntb where col2>=5")
|
||||
tdSql.query(f"select min(col1) from {dbname}.ntb where col2>=5")
|
||||
tdSql.checkData(0,0,5)
|
||||
|
||||
tdSql.query(f"select min(now()) from {dbname}.stb_1")
|
||||
tdSql.checkRows(1)
|
||||
|
||||
tdSql.query(f"select first(ts) from {dbname}.stb_1")
|
||||
firstTs = tdSql.getData(0, 0)
|
||||
tdSql.query(f"select min(ts) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, firstTs)
|
||||
|
||||
tdSql.query(f"select first(ts) from {dbname}.stb_1")
|
||||
firstTs = tdSql.getData(0, 0)
|
||||
tdSql.query(f"select min(ts) from {dbname}.stb_1")
|
||||
tdSql.checkData(0, 0, firstTs)
|
||||
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
|
@ -24,9 +24,6 @@ from util.dnodes import tdDnodes
|
|||
from util.dnodes import *
|
||||
|
||||
class TDTestCase:
|
||||
updatecfgDict = {'maxSQLLength':1048576,'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):
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
|
|
|
@ -9,48 +9,46 @@ from util.cases import *
|
|||
|
||||
|
||||
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, powSql):
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
tdSql.init(conn.cursor())
|
||||
|
||||
def prepare_datas(self):
|
||||
|
||||
def prepare_datas(self, dbname="db"):
|
||||
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)
|
||||
tags (t1 int)
|
||||
'''
|
||||
)
|
||||
|
||||
|
||||
tdSql.execute(
|
||||
'''
|
||||
create table t1
|
||||
f'''
|
||||
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)
|
||||
'''
|
||||
)
|
||||
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):
|
||||
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(
|
||||
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("insert into 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("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()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
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(f"insert into {dbname}.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()+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("insert into 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()-810d, 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(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
|
||||
f'''insert into {dbname}.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 )
|
||||
|
@ -65,257 +63,182 @@ class TDTestCase:
|
|||
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
|
||||
'''
|
||||
)
|
||||
|
||||
def check_result_auto_pow2(self ,origin_query , pow_query):
|
||||
|
||||
def check_result_auto_pow(self ,base , origin_query , pow_query):
|
||||
pow_result = tdSql.getResult(pow_query)
|
||||
origin_result = tdSql.getResult(origin_query)
|
||||
|
||||
auto_result =[]
|
||||
|
||||
for row in origin_result:
|
||||
row_check = []
|
||||
for elem in row:
|
||||
if elem == None:
|
||||
elem = None
|
||||
else:
|
||||
elem = math.pow(elem,2)
|
||||
row_check.append(elem)
|
||||
auto_result.append(row_check)
|
||||
|
||||
check_status = True
|
||||
|
||||
for row_index , row in enumerate(pow_result):
|
||||
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):
|
||||
check_status = False
|
||||
elif auto_result[row_index][col_index] != None and (auto_result[row_index][col_index] - elem > 0.00000001):
|
||||
check_status = False
|
||||
else:
|
||||
pass
|
||||
if not check_status:
|
||||
tdLog.notice("pow function value has not as expected , sql is \"%s\" "%pow_query )
|
||||
sys.exit(1)
|
||||
else:
|
||||
tdLog.info("pow value check pass , it work as expected ,sql is \"%s\" "%pow_query )
|
||||
|
||||
def check_result_auto_pow1(self ,origin_query , pow_query):
|
||||
pow_result = tdSql.getResult(pow_query)
|
||||
origin_result = tdSql.getResult(origin_query)
|
||||
|
||||
auto_result =[]
|
||||
|
||||
for row in origin_result:
|
||||
row_check = []
|
||||
for elem in row:
|
||||
if elem == None:
|
||||
elem = None
|
||||
else :
|
||||
elem = pow(elem ,1)
|
||||
elem = float(pow(elem ,base))
|
||||
row_check.append(elem)
|
||||
auto_result.append(row_check)
|
||||
|
||||
check_status = True
|
||||
tdSql.query(pow_query)
|
||||
for row_index , row in enumerate(pow_result):
|
||||
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):
|
||||
check_status = False
|
||||
elif auto_result[row_index][col_index] != None and (auto_result[row_index][col_index] - elem > 0.00000001):
|
||||
check_status = False
|
||||
else:
|
||||
pass
|
||||
if not check_status:
|
||||
tdLog.notice("pow function value has not as expected , sql is \"%s\" "%pow_query )
|
||||
sys.exit(1)
|
||||
else:
|
||||
tdLog.info("pow value check pass , it work as expected ,sql is \"%s\" "%pow_query )
|
||||
tdSql.checkData(row_index,col_index ,auto_result[row_index][col_index])
|
||||
|
||||
|
||||
def check_result_auto_pow__10(self ,origin_query , pow_query):
|
||||
pow_result = tdSql.getResult(pow_query)
|
||||
origin_result = tdSql.getResult(origin_query)
|
||||
|
||||
auto_result =[]
|
||||
|
||||
for row in origin_result:
|
||||
row_check = []
|
||||
for elem in row:
|
||||
if elem == None:
|
||||
elem = None
|
||||
elif elem == 0:
|
||||
elem = None
|
||||
else:
|
||||
elem = pow(elem ,-10)
|
||||
row_check.append(elem)
|
||||
auto_result.append(row_check)
|
||||
|
||||
check_status = True
|
||||
for row_index , row in enumerate(pow_result):
|
||||
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):
|
||||
check_status = False
|
||||
elif auto_result[row_index][col_index] != None and (auto_result[row_index][col_index] - elem > 0.00000001):
|
||||
check_status = False
|
||||
else:
|
||||
pass
|
||||
if not check_status:
|
||||
tdLog.notice("pow function value has not as expected , sql is \"%s\" "%pow_query )
|
||||
sys.exit(1)
|
||||
else:
|
||||
tdLog.info("pow 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 = [
|
||||
"select pow from t1",
|
||||
# "select pow(-+--+c1 ,2) from t1",
|
||||
# "select +-pow(c1,2) from t1",
|
||||
# "select ++-pow(c1,2) from t1",
|
||||
# "select ++--pow(c1,2) from t1",
|
||||
# "select - -pow(c1,2)*0 from t1",
|
||||
# "select pow(tbname+1,2) from t1 ",
|
||||
"select pow(123--123,2)==1 from t1",
|
||||
"select pow(c1,2) as 'd1' from t1",
|
||||
"select pow(c1 ,c2 ,2) from t1",
|
||||
"select pow(c1 ,NULL ,2) from t1",
|
||||
"select pow(, 2) from t1;",
|
||||
"select pow(pow(c1, 2) ab from t1)",
|
||||
"select pow(c1 ,2 ) as int from t1",
|
||||
"select pow from stb1",
|
||||
# "select pow(-+--+c1) from stb1",
|
||||
# "select +-pow(c1) from stb1",
|
||||
# "select ++-pow(c1) from stb1",
|
||||
# "select ++--pow(c1) from stb1",
|
||||
# "select - -pow(c1)*0 from stb1",
|
||||
# "select pow(tbname+1) from stb1 ",
|
||||
"select pow(123--123 ,2)==1 from stb1",
|
||||
"select pow(c1 ,2) as 'd1' from stb1",
|
||||
"select pow(c1 ,c2 ,2 ) from stb1",
|
||||
"select pow(c1 ,NULL,2) from stb1",
|
||||
"select pow(,) from stb1;",
|
||||
"select pow(pow(c1 , 2) ab from stb1)",
|
||||
"select pow(c1 , 2) as int from stb1"
|
||||
f"select pow from {dbname}.t1",
|
||||
# f"select pow(-+--+c1 ,2) from {dbname}.t1",
|
||||
# f"select +-pow(c1,2) from {dbname}.t1",
|
||||
# f"select ++-pow(c1,2) from {dbname}.t1",
|
||||
# f"select ++--pow(c1,2) from {dbname}.t1",
|
||||
# f"select - -pow(c1,2)*0 from {dbname}.t1",
|
||||
# f"select pow(tbname+1,2) from {dbname}.t1 ",
|
||||
f"select pow(123--123,2)==1 from {dbname}.t1",
|
||||
f"select pow(c1,2) as 'd1' from {dbname}.t1",
|
||||
f"select pow(c1 ,c2 ,2) from {dbname}.t1",
|
||||
f"select pow(c1 ,NULL ,2) from {dbname}.t1",
|
||||
f"select pow(, 2) from {dbname}.t1;",
|
||||
f"select pow(pow(c1, 2) ab from {dbname}.t1)",
|
||||
f"select pow(c1 ,2 ) as int from {dbname}.t1",
|
||||
f"select pow from {dbname}.stb1",
|
||||
# f"select pow(-+--+c1) from {dbname}.stb1",
|
||||
# f"select +-pow(c1) from {dbname}.stb1",
|
||||
# f"select ++-pow(c1) from {dbname}.stb1",
|
||||
# f"select ++--pow(c1) from {dbname}.stb1",
|
||||
# f"select - -pow(c1)*0 from {dbname}.stb1",
|
||||
# f"select pow(tbname+1) from {dbname}.stb1 ",
|
||||
f"select pow(123--123 ,2)==1 from {dbname}.stb1",
|
||||
f"select pow(c1 ,2) as 'd1' from {dbname}.stb1",
|
||||
f"select pow(c1 ,c2 ,2 ) from {dbname}.stb1",
|
||||
f"select pow(c1 ,NULL,2) from {dbname}.stb1",
|
||||
f"select pow(,) from {dbname}.stb1;",
|
||||
f"select pow(pow(c1 , 2) ab from {dbname}.stb1)",
|
||||
f"select pow(c1 , 2) as int from {dbname}.stb1"
|
||||
]
|
||||
for error_sql in error_sql_lists:
|
||||
tdSql.error(error_sql)
|
||||
|
||||
def support_types(self):
|
||||
|
||||
def support_types(self, dbname="db"):
|
||||
type_error_sql_lists = [
|
||||
"select pow(ts ,2 ) from t1" ,
|
||||
"select pow(c7,c1 ) from t1",
|
||||
"select pow(c8,c2) from t1",
|
||||
"select pow(c9,c3 ) from t1",
|
||||
"select pow(ts,c4 ) from ct1" ,
|
||||
"select pow(c7,c5 ) from ct1",
|
||||
"select pow(c8,c6 ) from ct1",
|
||||
"select pow(c9,c8 ) from ct1",
|
||||
"select pow(ts,2 ) from ct3" ,
|
||||
"select pow(c7,2 ) from ct3",
|
||||
"select pow(c8,2 ) from ct3",
|
||||
"select pow(c9,2 ) from ct3",
|
||||
"select pow(ts,2 ) from ct4" ,
|
||||
"select pow(c7,2 ) from ct4",
|
||||
"select pow(c8,2 ) from ct4",
|
||||
"select pow(c9,2 ) from ct4",
|
||||
"select pow(ts,2 ) from stb1" ,
|
||||
"select pow(c7,2 ) from stb1",
|
||||
"select pow(c8,2 ) from stb1",
|
||||
"select pow(c9,2 ) from stb1" ,
|
||||
f"select pow(ts ,2 ) from {dbname}.t1" ,
|
||||
f"select pow(c7,c1 ) from {dbname}.t1",
|
||||
f"select pow(c8,c2) from {dbname}.t1",
|
||||
f"select pow(c9,c3 ) from {dbname}.t1",
|
||||
f"select pow(ts,c4 ) from {dbname}.ct1" ,
|
||||
f"select pow(c7,c5 ) from {dbname}.ct1",
|
||||
f"select pow(c8,c6 ) from {dbname}.ct1",
|
||||
f"select pow(c9,c8 ) from {dbname}.ct1",
|
||||
f"select pow(ts,2 ) from {dbname}.ct3" ,
|
||||
f"select pow(c7,2 ) from {dbname}.ct3",
|
||||
f"select pow(c8,2 ) from {dbname}.ct3",
|
||||
f"select pow(c9,2 ) from {dbname}.ct3",
|
||||
f"select pow(ts,2 ) from {dbname}.ct4" ,
|
||||
f"select pow(c7,2 ) from {dbname}.ct4",
|
||||
f"select pow(c8,2 ) from {dbname}.ct4",
|
||||
f"select pow(c9,2 ) from {dbname}.ct4",
|
||||
f"select pow(ts,2 ) from {dbname}.stb1" ,
|
||||
f"select pow(c7,2 ) from {dbname}.stb1",
|
||||
f"select pow(c8,2 ) from {dbname}.stb1",
|
||||
f"select pow(c9,2 ) from {dbname}.stb1" ,
|
||||
|
||||
"select pow(ts,2 ) from stbbb1" ,
|
||||
"select pow(c7,2 ) from stbbb1",
|
||||
f"select pow(ts,2 ) from {dbname}.stbbb1" ,
|
||||
f"select pow(c7,2 ) from {dbname}.stbbb1",
|
||||
|
||||
"select pow(ts,2 ) from tbname",
|
||||
"select pow(c9,2 ) from tbname"
|
||||
f"select pow(ts,2 ) from {dbname}.tbname",
|
||||
f"select pow(c9,2 ) from {dbname}.tbname"
|
||||
|
||||
]
|
||||
|
||||
|
||||
for type_sql in type_error_sql_lists:
|
||||
tdSql.error(type_sql)
|
||||
|
||||
|
||||
|
||||
|
||||
type_sql_lists = [
|
||||
"select pow(c1,2 ) from t1",
|
||||
"select pow(c2,2 ) from t1",
|
||||
"select pow(c3,2 ) from t1",
|
||||
"select pow(c4,2 ) from t1",
|
||||
"select pow(c5,2 ) from t1",
|
||||
"select pow(c6,2 ) from t1",
|
||||
f"select pow(c1,2 ) from {dbname}.t1",
|
||||
f"select pow(c2,2 ) from {dbname}.t1",
|
||||
f"select pow(c3,2 ) from {dbname}.t1",
|
||||
f"select pow(c4,2 ) from {dbname}.t1",
|
||||
f"select pow(c5,2 ) from {dbname}.t1",
|
||||
f"select pow(c6,2 ) from {dbname}.t1",
|
||||
|
||||
"select pow(c1,2 ) from ct1",
|
||||
"select pow(c2,2 ) from ct1",
|
||||
"select pow(c3,2 ) from ct1",
|
||||
"select pow(c4,2 ) from ct1",
|
||||
"select pow(c5,2 ) from ct1",
|
||||
"select pow(c6,2 ) from ct1",
|
||||
f"select pow(c1,2 ) from {dbname}.ct1",
|
||||
f"select pow(c2,2 ) from {dbname}.ct1",
|
||||
f"select pow(c3,2 ) from {dbname}.ct1",
|
||||
f"select pow(c4,2 ) from {dbname}.ct1",
|
||||
f"select pow(c5,2 ) from {dbname}.ct1",
|
||||
f"select pow(c6,2 ) from {dbname}.ct1",
|
||||
|
||||
"select pow(c1,2 ) from ct3",
|
||||
"select pow(c2,2 ) from ct3",
|
||||
"select pow(c3,2 ) from ct3",
|
||||
"select pow(c4,2 ) from ct3",
|
||||
"select pow(c5,2 ) from ct3",
|
||||
"select pow(c6,2 ) from ct3",
|
||||
f"select pow(c1,2 ) from {dbname}.ct3",
|
||||
f"select pow(c2,2 ) from {dbname}.ct3",
|
||||
f"select pow(c3,2 ) from {dbname}.ct3",
|
||||
f"select pow(c4,2 ) from {dbname}.ct3",
|
||||
f"select pow(c5,2 ) from {dbname}.ct3",
|
||||
f"select pow(c6,2 ) from {dbname}.ct3",
|
||||
|
||||
"select pow(c1,2 ) from stb1",
|
||||
"select pow(c2,2 ) from stb1",
|
||||
"select pow(c3,2 ) from stb1",
|
||||
"select pow(c4,2 ) from stb1",
|
||||
"select pow(c5,2 ) from stb1",
|
||||
"select pow(c6,2 ) from stb1",
|
||||
f"select pow(c1,2 ) from {dbname}.stb1",
|
||||
f"select pow(c2,2 ) from {dbname}.stb1",
|
||||
f"select pow(c3,2 ) from {dbname}.stb1",
|
||||
f"select pow(c4,2 ) from {dbname}.stb1",
|
||||
f"select pow(c5,2 ) from {dbname}.stb1",
|
||||
f"select pow(c6,2 ) from {dbname}.stb1",
|
||||
|
||||
"select pow(c6,2) as alisb from stb1",
|
||||
"select pow(c6,2) alisb from stb1",
|
||||
f"select pow(c6,2) as alisb from {dbname}.stb1",
|
||||
f"select pow(c6,2) alisb from {dbname}.stb1",
|
||||
]
|
||||
|
||||
for type_sql in type_sql_lists:
|
||||
tdSql.query(type_sql)
|
||||
|
||||
def basic_pow_function(self):
|
||||
|
||||
# basic query
|
||||
tdSql.query("select c1 from ct3")
|
||||
def basic_pow_function(self, dbname="db"):
|
||||
|
||||
# basic query
|
||||
tdSql.query(f"select c1 from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select c1 from t1")
|
||||
tdSql.query(f"select c1 from {dbname}.t1")
|
||||
tdSql.checkRows(12)
|
||||
tdSql.query("select c1 from stb1")
|
||||
tdSql.query(f"select c1 from {dbname}.stb1")
|
||||
tdSql.checkRows(25)
|
||||
|
||||
# used for empty table , ct3 is empty
|
||||
tdSql.query("select pow(c1 ,2) from ct3")
|
||||
tdSql.query(f"select pow(c1 ,2) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select pow(c2 ,2) from ct3")
|
||||
tdSql.query(f"select pow(c2 ,2) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select pow(c3 ,2) from ct3")
|
||||
tdSql.query(f"select pow(c3 ,2) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select pow(c4 ,2) from ct3")
|
||||
tdSql.query(f"select pow(c4 ,2) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select pow(c5 ,2) from ct3")
|
||||
tdSql.query(f"select pow(c5 ,2) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select pow(c6 ,2) from ct3")
|
||||
tdSql.query(f"select pow(c6 ,2) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
|
||||
|
||||
# # used for regular table
|
||||
tdSql.query("select pow(c1 ,2) from t1")
|
||||
tdSql.query(f"select pow(c1 ,2) from {dbname}.t1")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(1 , 0, 1.000000000)
|
||||
tdSql.checkData(3 , 0, 9.000000000)
|
||||
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(3, 3, 33)
|
||||
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(3, 4, 33)
|
||||
tdSql.checkData(5, 5, None)
|
||||
|
||||
self.check_result_auto_pow2( "select c1, c2, c3 , c4, c5 from t1", "select pow(c1 ,2), pow(c2 ,2) ,pow(c3, 2), pow(c4 ,2), pow(c5 ,2) from t1")
|
||||
self.check_result_auto_pow1( "select c1, c2, c3 , c4, c5 from t1", "select pow(c1 ,1), pow(c2 ,1) ,pow(c3, 1), pow(c4 ,1), pow(c5 ,1) from t1")
|
||||
self.check_result_auto_pow__10( "select c1, c2, c3 , c4, c5 from t1", "select pow(c1 ,-10), pow(c2 ,-10) ,pow(c3, -10), pow(c4 ,-10), pow(c5 ,-10) from t1")
|
||||
|
||||
self.check_result_auto_pow( 2, f"select c1, c3 , c4, c5 from {dbname}.t1", f"select pow(c1 ,2) , pow(c3, 2), pow(c4 ,2), pow(c5 ,2) from {dbname}.t1")
|
||||
self.check_result_auto_pow( 1,f"select c1, c3 , c4, c5 from {dbname}.t1", f"select pow(c1 ,1) , pow(c3, 1), pow(c4 ,1), pow(c5 ,1) from {dbname}.t1")
|
||||
self.check_result_auto_pow( 10,f"select c1, c3 , c4, c5 from {dbname}.t1", f"select pow(c1 ,10) ,pow(c3, 10), pow(c4 ,10), pow(c5 ,10) from {dbname}.t1")
|
||||
|
||||
# used for sub table
|
||||
tdSql.query("select c1 ,pow(c1 ,2) from ct1")
|
||||
tdSql.query(f"select c1 ,pow(c1 ,2) from {dbname}.ct1")
|
||||
tdSql.checkData(0, 1, 64.000000000)
|
||||
tdSql.checkData(1 , 1, 49.000000000)
|
||||
tdSql.checkData(3 , 1, 25.000000000)
|
||||
|
@ -323,7 +246,7 @@ class TDTestCase:
|
|||
|
||||
# # test bug fix for pow(c1,c2)
|
||||
|
||||
tdSql.query("select c1, c5 ,pow(c1,c5) from ct4")
|
||||
tdSql.query(f"select c1, c5 ,pow(c1,c5) from {dbname}.ct4")
|
||||
tdSql.checkData(0 , 2, None)
|
||||
tdSql.checkData(1 , 2, 104577724.506799981)
|
||||
tdSql.checkData(2 , 2, 3684781.623933245)
|
||||
|
@ -331,11 +254,11 @@ class TDTestCase:
|
|||
tdSql.checkData(4 , 2, 7573.273783071)
|
||||
|
||||
|
||||
self.check_result_auto_pow2( "select c1, c2, c3 , c4, c5 from ct1", "select pow(c1,2), pow(c2,2) ,pow(c3,2), pow(c4,2), pow(c5,2) from ct1")
|
||||
self.check_result_auto_pow__10( "select c1, c2, c3 , c4, c5 from ct1", "select pow(c1,-10), pow(c2,-10) ,pow(c3,-10), pow(c4,-10), pow(c5,-10) from ct1")
|
||||
self.check_result_auto_pow( 2, f"select c1, c3 , c4, c5 from {dbname}.ct1", f"select pow(c1,2), pow(c3,2), pow(c4,2), pow(c5,2) from {dbname}.ct1")
|
||||
self.check_result_auto_pow( 10, f"select c1, c3 , c4, c5 from {dbname}.ct1", f"select pow(c1,10), pow(c3,10), pow(c4,10), pow(c5,10) from {dbname}.ct1")
|
||||
|
||||
# nest query for pow functions
|
||||
tdSql.query("select c1 , pow(c1,2) ,pow(pow(c1,2),2) , pow(pow(pow(c1,2),2),2) from ct1;")
|
||||
tdSql.query(f"select c1 , pow(c1,2) ,pow(pow(c1,2),2) , pow(pow(pow(c1,2),2),2) from {dbname}.ct1;")
|
||||
tdSql.checkData(0 , 0 , 8)
|
||||
tdSql.checkData(0 , 1 , 64.000000000)
|
||||
tdSql.checkData(0 , 2 , 4096.000000000)
|
||||
|
@ -351,24 +274,24 @@ class TDTestCase:
|
|||
tdSql.checkData(4 , 2 , 0.000000000)
|
||||
tdSql.checkData(4 , 3 , 0.000000000)
|
||||
|
||||
# # used for stable table
|
||||
|
||||
tdSql.query("select pow(c1, 2) from stb1")
|
||||
# # used for stable table
|
||||
|
||||
tdSql.query(f"select pow(c1, 2) from {dbname}.stb1")
|
||||
tdSql.checkRows(25)
|
||||
|
||||
|
||||
|
||||
# used for not exists table
|
||||
tdSql.error("select pow(c1, 2) from stbbb1")
|
||||
tdSql.error("select pow(c1, 2) from tbname")
|
||||
tdSql.error("select pow(c1, 2) from ct5")
|
||||
tdSql.error(f"select pow(c1, 2) from {dbname}.stbbb1")
|
||||
tdSql.error(f"select pow(c1, 2) from {dbname}.tbname")
|
||||
tdSql.error(f"select pow(c1, 2) from {dbname}.ct5")
|
||||
|
||||
# mix with common col
|
||||
tdSql.query("select c1, pow(c1 ,2) from ct1")
|
||||
# mix with common col
|
||||
tdSql.query(f"select c1, pow(c1 ,2) from {dbname}.ct1")
|
||||
tdSql.checkData(0 , 0 ,8)
|
||||
tdSql.checkData(0 , 1 ,64.000000000)
|
||||
tdSql.checkData(4 , 0 ,0)
|
||||
tdSql.checkData(4 , 1 ,0.000000000)
|
||||
tdSql.query("select c1, pow(c1,2) from ct4")
|
||||
tdSql.query(f"select c1, pow(c1,2) from {dbname}.ct4")
|
||||
tdSql.checkData(0 , 0 , None)
|
||||
tdSql.checkData(0 , 1 ,None)
|
||||
tdSql.checkData(4 , 0 ,5)
|
||||
|
@ -377,45 +300,45 @@ class TDTestCase:
|
|||
tdSql.checkData(5 , 1 ,None)
|
||||
|
||||
# mix with common functions
|
||||
tdSql.query("select c1, pow(c1 ,2),pow(c1,2), log(pow(c1,2) ,2) from ct4 ")
|
||||
tdSql.query(f"select c1, pow(c1 ,2),pow(c1,2), log(pow(c1,2) ,2) from {dbname}.ct4 ")
|
||||
tdSql.checkData(0 , 0 ,None)
|
||||
tdSql.checkData(0 , 1 ,None)
|
||||
tdSql.checkData(0 , 2 ,None)
|
||||
tdSql.checkData(0 , 3 ,None)
|
||||
|
||||
|
||||
tdSql.checkData(3 , 0 , 6)
|
||||
tdSql.checkData(3 , 1 ,36.000000000)
|
||||
tdSql.checkData(3 , 2 ,36.000000000)
|
||||
tdSql.checkData(3 , 3 ,5.169925001)
|
||||
|
||||
tdSql.query("select c1, pow(c1,1),c5, floor(c5 ) from stb1 ")
|
||||
tdSql.query(f"select c1, pow(c1,1),c5, floor(c5 ) from {dbname}.stb1 ")
|
||||
|
||||
# # mix with agg functions , not support
|
||||
tdSql.error("select c1, pow(c1 ,2),c5, count(c5) from stb1 ")
|
||||
tdSql.error("select c1, pow(c1 ,2),c5, count(c5) from ct1 ")
|
||||
tdSql.error("select pow(c1 ,2), count(c5) from stb1 ")
|
||||
tdSql.error("select pow(c1 ,2), count(c5) from ct1 ")
|
||||
tdSql.error("select c1, count(c5) from ct1 ")
|
||||
tdSql.error("select c1, count(c5) from stb1 ")
|
||||
tdSql.error(f"select c1, pow(c1 ,2),c5, count(c5) from {dbname}.stb1 ")
|
||||
tdSql.error(f"select c1, pow(c1 ,2),c5, count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select pow(c1 ,2), count(c5) from {dbname}.stb1 ")
|
||||
tdSql.error(f"select pow(c1 ,2), count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ")
|
||||
|
||||
# agg functions mix with agg functions
|
||||
|
||||
tdSql.query("select max(c5), count(c5) from stb1")
|
||||
tdSql.query("select max(c5), count(c5) from ct1")
|
||||
tdSql.query(f"select max(c5), count(c5) from {dbname}.stb1")
|
||||
tdSql.query(f"select max(c5), count(c5) from {dbname}.ct1")
|
||||
|
||||
|
||||
|
||||
# bug fix for count
|
||||
tdSql.query("select count(c1) from ct4 ")
|
||||
tdSql.query(f"select count(c1) from {dbname}.ct4 ")
|
||||
tdSql.checkData(0,0,9)
|
||||
tdSql.query("select count(*) from ct4 ")
|
||||
tdSql.query(f"select count(*) from {dbname}.ct4 ")
|
||||
tdSql.checkData(0,0,12)
|
||||
tdSql.query("select count(c1) from stb1 ")
|
||||
tdSql.query(f"select count(c1) from {dbname}.stb1 ")
|
||||
tdSql.checkData(0,0,22)
|
||||
tdSql.query("select count(*) from stb1 ")
|
||||
tdSql.query(f"select count(*) from {dbname}.stb1 ")
|
||||
tdSql.checkData(0,0,25)
|
||||
|
||||
# # bug fix for compute
|
||||
tdSql.query("select c1, pow(c1 ,2) -0 ,pow(c1-4 ,2)-0 from ct4 ")
|
||||
# # bug fix for compute
|
||||
tdSql.query(f"select c1, pow(c1 ,2) -0 ,pow(c1-4 ,2)-0 from {dbname}.ct4 ")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(0, 2, None)
|
||||
|
@ -423,7 +346,7 @@ class TDTestCase:
|
|||
tdSql.checkData(1, 1, 64.000000000)
|
||||
tdSql.checkData(1, 2, 16.000000000)
|
||||
|
||||
tdSql.query(" select c1, pow(c1 ,2) -0 ,pow(c1-0.1 ,2)-0.1 from ct4")
|
||||
tdSql.query(f"select c1, pow(c1 ,2) -0 ,pow(c1-0.1 ,2)-0.1 from {dbname}.ct4")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(0, 2, None)
|
||||
|
@ -431,87 +354,86 @@ class TDTestCase:
|
|||
tdSql.checkData(1, 1, 64.000000000)
|
||||
tdSql.checkData(1, 2, 62.310000000)
|
||||
|
||||
tdSql.query("select c1, pow(c1, -10), c2, pow(c2, -10), c3, pow(c3, -10) from ct1")
|
||||
tdSql.query(f"select c1, pow(c1, -10), c2, pow(c2, -10), c3, pow(c3, -10) from {dbname}.ct1")
|
||||
|
||||
def test_big_number(self):
|
||||
def test_big_number(self, dbname="db"):
|
||||
|
||||
tdSql.query("select c1, pow(c1, 100000000) from ct1") # bigint to double data overflow
|
||||
tdSql.query(f"select c1, pow(c1, 100000000) from {dbname}.ct1") # bigint to double data overflow
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(1, 1, None)
|
||||
tdSql.checkData(4, 1, 0.000000000)
|
||||
|
||||
|
||||
tdSql.query("select c1, pow(c1, 10000000000000) from ct1") # bigint to double data overflow
|
||||
tdSql.query(f"select c1, pow(c1, 10000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(1, 1, None)
|
||||
tdSql.checkData(4, 1, 0.000000000)
|
||||
|
||||
tdSql.query("select c1, pow(c1, 10000000000000000000000000) from ct1") # bigint to double data overflow
|
||||
tdSql.query("select c1, pow(c1, 10000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value
|
||||
tdSql.query(f"select c1, pow(c1, 10000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||
tdSql.query(f"select c1, pow(c1, 10000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(1, 1, None)
|
||||
tdSql.checkData(4, 1, 0.000000000)
|
||||
|
||||
tdSql.query("select c1, pow(c1, 10000000000000000000000000000000000) from ct1") # bigint to double data overflow
|
||||
tdSql.query("select c1, pow(c1, 10000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value
|
||||
tdSql.query(f"select c1, pow(c1, 10000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||
tdSql.query(f"select c1, pow(c1, 10000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(1, 1, None)
|
||||
tdSql.checkData(4, 1, 0.000000000)
|
||||
|
||||
tdSql.query("select c1, pow(c1, 10000000000000000000000000000000000000000) from ct1") # bigint to double data overflow
|
||||
tdSql.query("select c1, pow(c1, 10000000000000000000000000000000000000000.0) from ct1") # 10000000000000000000000000.0 is a double value
|
||||
tdSql.query(f"select c1, pow(c1, 10000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||
tdSql.query(f"select c1, pow(c1, 10000000000000000000000000000000000000000.0) from {dbname}.ct1") # 10000000000000000000000000.0 is a double value
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(1, 1, None)
|
||||
tdSql.checkData(4, 1, 0.000000000)
|
||||
|
||||
tdSql.query("select c1, pow(c1, 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from ct1") # bigint to double data overflow
|
||||
tdSql.query(f"select c1, pow(c1, 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) from {dbname}.ct1") # bigint to double data overflow
|
||||
|
||||
def pow_base_test(self):
|
||||
def pow_base_test(self, dbname="db"):
|
||||
|
||||
# base is an regular number ,int or double
|
||||
tdSql.query("select c1, pow(c1, 2) from ct1")
|
||||
tdSql.query(f"select c1, pow(c1, 2) from {dbname}.ct1")
|
||||
tdSql.checkData(0, 1,64.000000000)
|
||||
tdSql.query("select c1, pow(c1, 2.0) from ct1")
|
||||
tdSql.query(f"select c1, pow(c1, 2.0) from {dbname}.ct1")
|
||||
tdSql.checkData(0, 1, 64.000000000)
|
||||
|
||||
tdSql.query("select c1, pow(1, 2.0) from ct1")
|
||||
tdSql.query(f"select c1, pow(1, 2.0) from {dbname}.ct1")
|
||||
tdSql.checkData(0, 1, 1.000000000)
|
||||
tdSql.checkRows(13)
|
||||
|
||||
|
||||
# # bug for compute in functions
|
||||
# tdSql.query("select c1, abs(1/0) from ct1")
|
||||
# tdSql.query(f"select c1, abs(1/0) from {dbname}.ct1")
|
||||
# tdSql.checkData(0, 0, 8)
|
||||
# tdSql.checkData(0, 1, 1)
|
||||
|
||||
tdSql.query("select c1, pow(1, 2.0) from ct1")
|
||||
tdSql.query(f"select c1, pow(1, 2.0) from {dbname}.ct1")
|
||||
tdSql.checkData(0, 1, 1.000000000)
|
||||
tdSql.checkRows(13)
|
||||
|
||||
# two cols start pow(x,y)
|
||||
tdSql.query("select c1,c2, pow(c1,c2) from ct1")
|
||||
tdSql.query(f"select c1,c2, pow(c1,c2) from {dbname}.ct1")
|
||||
tdSql.checkData(0, 2, None)
|
||||
tdSql.checkData(1, 2, None)
|
||||
tdSql.checkData(4, 2, 1.000000000)
|
||||
|
||||
tdSql.query("select c1,c2, pow(c2,c1) from ct1")
|
||||
tdSql.query(f"select c1,c2, pow(c2,c1) from {dbname}.ct1")
|
||||
tdSql.checkData(0, 2, 3897131646727578700481513520437089271808.000000000)
|
||||
tdSql.checkData(1, 2, 17217033054561120738612297152331776.000000000)
|
||||
tdSql.checkData(4, 2, 1.000000000)
|
||||
|
||||
tdSql.query("select c1, pow(2.0 , c1) from ct1")
|
||||
tdSql.query(f"select c1, pow(2.0 , c1) from {dbname}.ct1")
|
||||
tdSql.checkData(0, 1, 256.000000000)
|
||||
tdSql.checkData(1, 1, 128.000000000)
|
||||
tdSql.checkData(4, 1, 1.000000000)
|
||||
|
||||
tdSql.query("select c1, pow(2.0 , c1) from ct1")
|
||||
tdSql.query(f"select c1, pow(2.0 , c1) from {dbname}.ct1")
|
||||
tdSql.checkData(0, 1, 256.000000000)
|
||||
tdSql.checkData(1, 1, 128.000000000)
|
||||
tdSql.checkData(4, 1, 1.000000000)
|
||||
|
||||
def abs_func_filter(self):
|
||||
tdSql.execute("use db")
|
||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(pow(c1,2)-0.5) from ct4 where c1>5 ")
|
||||
def abs_func_filter(self, dbname="db"):
|
||||
tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(pow(c1,2)-0.5) from {dbname}.ct4 where c1>5 ")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,0,8)
|
||||
tdSql.checkData(0,1,8.000000000)
|
||||
|
@ -519,7 +441,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0,3,7.900000000)
|
||||
tdSql.checkData(0,4,64.000000000)
|
||||
|
||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(pow(c1,2)-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(pow(c1,2)-0.5) from {dbname}.ct4 where c1=5 ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,5)
|
||||
tdSql.checkData(0,1,5.000000000)
|
||||
|
@ -527,7 +449,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0,3,4.900000000)
|
||||
tdSql.checkData(0,4,25.000000000)
|
||||
|
||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(pow(c1,2)-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(pow(c1,2)-0.5) from {dbname}.ct4 where c1=5 ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,5)
|
||||
tdSql.checkData(0,1,5.000000000)
|
||||
|
@ -535,7 +457,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0,3,4.900000000)
|
||||
tdSql.checkData(0,4,25.000000000)
|
||||
|
||||
tdSql.query("select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(pow(c1,2)-0.5) from ct4 where c1<pow(c1,2) limit 1 ")
|
||||
tdSql.query(f"select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(pow(c1,2)-0.5) from {dbname}.ct4 where c1<pow(c1,2) limit 1 ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,8)
|
||||
tdSql.checkData(0,1,88888)
|
||||
|
@ -543,45 +465,41 @@ class TDTestCase:
|
|||
tdSql.checkData(0,3,8.000000000)
|
||||
tdSql.checkData(0,4,7.900000000)
|
||||
tdSql.checkData(0,5,64.000000000)
|
||||
|
||||
def pow_Arithmetic(self):
|
||||
pass
|
||||
|
||||
def check_boundary_values(self):
|
||||
|
||||
tdSql.execute("drop database if exists bound_test")
|
||||
tdSql.execute("create database if not exists bound_test")
|
||||
def check_boundary_values(self, dbname="bound_test"):
|
||||
|
||||
tdSql.execute(f"drop database if exists {dbname}")
|
||||
tdSql.execute(f"create database if not exists {dbname}")
|
||||
time.sleep(3)
|
||||
tdSql.execute("use bound_test")
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.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_pow2( "select c1, c2, c3 , c4, c5 from sub1_bound ", "select pow(c1,2), pow(c2,2) ,pow(c3,2), pow(c4,2), pow(c5,2) from sub1_bound")
|
||||
self.check_result_auto_pow__10( "select c1, c2, c3 , c4, c5 from sub1_bound ", "select pow(c1,-10), pow(c2,-10) ,pow(c3,-10), pow(c4,-10), pow(c5,-10) from sub1_bound")
|
||||
|
||||
self.check_result_auto_pow2( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select pow(c1,2), pow(c2,2) ,pow(c3,2), pow(c3,2), pow(c2,2) ,pow(c1,2) from sub1_bound")
|
||||
self.check_result_auto_pow(2, f"select c1, c3 , c4, c5 from {dbname}.sub1_bound ", f"select pow(c1,2), pow(c3,2), pow(c4,2), pow(c5,2) from {dbname}.sub1_bound")
|
||||
self.check_result_auto_pow(3, f"select c1, c3 , c4, c5 from {dbname}.sub1_bound ", f"select pow(c1,3), pow(c3,3), pow(c4,3), pow(c5,3) from {dbname}.sub1_bound")
|
||||
|
||||
self.check_result_auto_pow(2, f"select c1, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select pow(c1,2), pow(c3,2), pow(c3,2), pow(c2,2) ,pow(c1,2) from {dbname}.sub1_bound")
|
||||
|
||||
|
||||
self.check_result_auto_pow2("select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from sub1_bound" , "select pow(abs(c1) ,2) from sub1_bound" )
|
||||
|
||||
self.check_result_auto_pow(2, f"select abs(abs(abs(abs(abs(abs(abs(abs(abs(c1))))))))) nest_col_func from {dbname}.sub1_bound" , f"select pow(abs(c1) ,2) from {dbname}.sub1_bound" )
|
||||
|
||||
# check basic elem for table per row
|
||||
tdSql.query("select pow(abs(c1),2) ,pow(abs(c2),2) , pow(abs(c3),2) , pow(abs(c4),2), pow(abs(c5),2), pow(abs(c6),2) from sub1_bound ")
|
||||
tdSql.query(f"select pow(abs(c1),2) ,pow(abs(c2),2) , pow(abs(c3),2) , pow(abs(c4),2), pow(abs(c5),2), pow(abs(c6),2) from {dbname}.sub1_bound ")
|
||||
tdSql.checkData(0,0,math.pow(2147483647,2))
|
||||
tdSql.checkData(0,1,math.pow(9223372036854775807 ,2))
|
||||
tdSql.checkData(0,2,math.pow(32767,2))
|
||||
|
@ -597,70 +515,65 @@ class TDTestCase:
|
|||
tdSql.checkData(3,2,math.pow(32766,2))
|
||||
tdSql.checkData(3,3,math.pow(126 ,2))
|
||||
tdSql.checkData(3,4,math.pow(339999995214436424907732413799364296704.00000,2))
|
||||
|
||||
|
||||
# check + - * / in functions
|
||||
tdSql.query("select pow(abs(c1+1) ,2) ,pow(abs(c2),2) , pow(abs(c3*1),2) , pow(abs(c4/2),2), pow(abs(c5) ,2)/2, pow(abs(c6) ,2) from sub1_bound ")
|
||||
tdSql.query(f"select pow(abs(c1+1) ,2) ,pow(abs(c2),2) , pow(abs(c3*1),2) , pow(abs(c4/2),2), pow(abs(c5) ,2)/2, pow(abs(c6) ,2) from {dbname}.sub1_bound ")
|
||||
tdSql.checkData(0,0,math.pow(2147483648.000000000,2))
|
||||
tdSql.checkData(0,1,math.pow(9223372036854775807,2))
|
||||
tdSql.checkData(0,2,math.pow(32767.000000000,2))
|
||||
tdSql.checkData(0,3,math.pow(63.500000000,2))
|
||||
tdSql.checkData(0,5,None)
|
||||
|
||||
|
||||
def support_super_table_test(self):
|
||||
tdSql.execute(" use db ")
|
||||
self.check_result_auto_pow2( " select c5 from stb1 order by ts " , "select pow(c5,2) from stb1 order by ts" )
|
||||
self.check_result_auto_pow2( " select c5 from stb1 order by tbname " , "select pow(c5,2) from stb1 order by tbname" )
|
||||
self.check_result_auto_pow2( " select c5 from stb1 where c1 > 0 order by tbname " , "select pow(c5,2) from stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto_pow2( " select c5 from stb1 where c1 > 0 order by tbname " , "select pow(c5,2) from stb1 where c1 > 0 order by tbname" )
|
||||
|
||||
self.check_result_auto_pow2( " select t1,c5 from stb1 order by ts " , "select pow(t1,2), pow(c5,2) from stb1 order by ts" )
|
||||
self.check_result_auto_pow2( " select t1,c5 from stb1 order by tbname " , "select pow(t1,2) ,pow(c5,2) from stb1 order by tbname" )
|
||||
self.check_result_auto_pow2( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select pow(t1,2) ,pow(c5,2) from stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto_pow2( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select pow(t1,2) , pow(c5,2) from stb1 where c1 > 0 order by tbname" )
|
||||
pass
|
||||
|
||||
|
||||
def support_super_table_test(self, dbname="db"):
|
||||
self.check_result_auto_pow(2, f"select c5 from {dbname}.stb1 order by ts " , f"select pow(c5,2) from {dbname}.stb1 order by ts" )
|
||||
self.check_result_auto_pow(2, f"select c5 from {dbname}.stb1 order by tbname " , f"select pow(c5,2) from {dbname}.stb1 order by tbname" )
|
||||
self.check_result_auto_pow(2, f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select pow(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto_pow(2, f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select pow(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
|
||||
self.check_result_auto_pow(2, f"select t1,c5 from {dbname}.stb1 order by ts " , f"select pow(t1,2), pow(c5,2) from {dbname}.stb1 order by ts" )
|
||||
self.check_result_auto_pow(2, f"select t1,c5 from {dbname}.stb1 order by tbname " , f"select pow(t1,2) ,pow(c5,2) from {dbname}.stb1 order by tbname" )
|
||||
self.check_result_auto_pow(2, f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select pow(t1,2) ,pow(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto_pow(2, f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select pow(t1,2) , pow(c5,2) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
|
||||
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
||||
tdSql.prepare()
|
||||
|
||||
tdLog.printNoPrefix("==========step1:create table ==============")
|
||||
|
||||
|
||||
self.prepare_datas()
|
||||
|
||||
tdLog.printNoPrefix("==========step2:test errors ==============")
|
||||
tdLog.printNoPrefix("==========step2:test errors ==============")
|
||||
|
||||
self.test_errors()
|
||||
|
||||
tdLog.printNoPrefix("==========step3:support types ============")
|
||||
|
||||
tdLog.printNoPrefix("==========step3:support types ============")
|
||||
|
||||
self.support_types()
|
||||
|
||||
tdLog.printNoPrefix("==========step4: pow basic query ============")
|
||||
tdLog.printNoPrefix("==========step4: pow basic query ============")
|
||||
|
||||
self.basic_pow_function()
|
||||
|
||||
tdLog.printNoPrefix("==========step5: big number pow query ============")
|
||||
tdLog.printNoPrefix("==========step5: big number pow query ============")
|
||||
|
||||
self.test_big_number()
|
||||
|
||||
tdLog.printNoPrefix("==========step6: base number for pow query ============")
|
||||
tdLog.printNoPrefix("==========step6: base number for pow query ============")
|
||||
|
||||
self.pow_base_test()
|
||||
|
||||
tdLog.printNoPrefix("==========step7: pow boundary query ============")
|
||||
tdLog.printNoPrefix("==========step7: pow boundary query ============")
|
||||
|
||||
self.check_boundary_values()
|
||||
|
||||
tdLog.printNoPrefix("==========step8: pow filter query ============")
|
||||
tdLog.printNoPrefix("==========step8: pow filter query ============")
|
||||
|
||||
self.abs_func_filter()
|
||||
|
||||
tdLog.printNoPrefix("==========step9: check pow result of stable query ============")
|
||||
|
||||
self.support_super_table_test()
|
||||
self.support_super_table_test()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
|
@ -13,9 +13,9 @@ from util.common import *
|
|||
|
||||
sys.path.append("./6-cluster/")
|
||||
from clusterCommonCreate import *
|
||||
from clusterCommonCheck import clusterComCheck
|
||||
from clusterCommonCheck import clusterComCheck
|
||||
|
||||
import threading
|
||||
import threading
|
||||
|
||||
class TDTestCase:
|
||||
|
||||
|
@ -28,7 +28,7 @@ class TDTestCase:
|
|||
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
tdSql.init(conn.cursor(), True)
|
||||
tdSql.init(conn.cursor(), False)
|
||||
|
||||
def create_ctable(self,tsql=None, dbName='dbx',stbName='stb',ctbPrefix='ctb',ctbNum=1):
|
||||
tsql.execute("use %s" %dbName)
|
||||
|
@ -47,7 +47,7 @@ class TDTestCase:
|
|||
sql = pre_create
|
||||
if sql != pre_create:
|
||||
tsql.execute(sql)
|
||||
|
||||
|
||||
tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName))
|
||||
return
|
||||
|
||||
|
@ -55,7 +55,7 @@ class TDTestCase:
|
|||
dbname="db_tsbs"
|
||||
stabname1="readings"
|
||||
stabname2="diagnostics"
|
||||
ctbnamePre1="rct"
|
||||
ctbnamePre1="rct"
|
||||
ctbnamePre2="dct"
|
||||
ctbNums=40
|
||||
self.ctbNums=ctbNums
|
||||
|
@ -73,7 +73,7 @@ class TDTestCase:
|
|||
self.create_ctable(tsql=tdSql,dbName=dbname,stbName=stabname2,ctbPrefix=ctbnamePre2,ctbNum=ctbNums)
|
||||
|
||||
|
||||
for j in range(ctbNums):
|
||||
for j in range(ctbNums):
|
||||
for i in range(rowNUms):
|
||||
tdSql.execute(
|
||||
f"insert into rct{j} values ( {ts+i*60000}, {80+i}, {90+i}, {85+i}, {30+i*10}, {1.2*i}, {221+i*2}, {20+i*0.2}, {1500+i*20}, {150+i*2},{5+i} )"
|
||||
|
@ -109,19 +109,19 @@ class TDTestCase:
|
|||
|
||||
def tsbsIotQuery(self,tdSql):
|
||||
tdSql.execute("use db_tsbs")
|
||||
|
||||
|
||||
# test interval and partition
|
||||
tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet; ")
|
||||
# print(tdSql.queryResult)
|
||||
parRows=tdSql.queryRows
|
||||
tdSql.query(" SELECT avg(velocity) as mean_velocity ,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet interval(10m); ")
|
||||
tdSql.checkRows(parRows)
|
||||
|
||||
|
||||
# # test insert into
|
||||
|
||||
|
||||
# # test insert into
|
||||
# tdSql.execute("create table testsnode (ts timestamp, c1 float,c2 binary(30),c3 binary(30),c4 binary(30)) ;")
|
||||
# tdSql.query("insert into testsnode SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);")
|
||||
|
||||
|
||||
# tdSql.query("insert into testsnode(ts,c1,c2,c3,c4) SELECT ts,avg(velocity) as mean_velocity,name,driver,fleet FROM readings WHERE ts > 1451606400000 AND ts <= 1451606460000 partition BY name,driver,fleet,ts interval(10m);")
|
||||
|
||||
|
||||
|
@ -141,7 +141,7 @@ class TDTestCase:
|
|||
|
||||
tdSql.query("SELECT ts,name,driver,current_load,load_capacity FROM (SELECT last(ts) as ts,name,driver, current_load,load_capacity FROM diagnostics WHERE fleet = 'South' partition by name,driver) WHERE current_load>= (0.9 * load_capacity) partition by name ORDER BY name ;")
|
||||
|
||||
# 2 stationary-trucks
|
||||
# 2 stationary-trucks
|
||||
tdSql.query("select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity FROM readings WHERE ts > '2016-01-01T15:07:21Z' AND ts <= '2016-01-01T16:17:21Z' partition BY name,driver,fleet interval(10m) LIMIT 1)")
|
||||
tdSql.query("select name,driver from (SELECT name,driver,fleet ,avg(velocity) as mean_velocity FROM readings WHERE ts > '2016-01-01T15:07:21Z' AND ts <= '2016-01-01T16:17:21Z' partition BY name,driver,fleet interval(10m) LIMIT 1) WHERE fleet = 'West' AND mean_velocity < 1000 partition BY name")
|
||||
|
||||
|
@ -156,7 +156,7 @@ class TDTestCase:
|
|||
tdSql.query("select _wstart as ts,fleet,name,driver,count(mv)/6 as hours_driven from ( select _wstart as ts,fleet,name,driver,avg(velocity) as mv from readings where ts > '2016-01-01T00:00:00Z' and ts < '2016-01-05T00:00:01Z' partition by fleet,name,driver interval(10m)) where ts > '2016-01-01T00:00:00Z' and ts < '2016-01-05T00:00:01Z' partition by fleet,name,driver interval(1d) ;")
|
||||
|
||||
|
||||
# # 6. avg-daily-driving-session
|
||||
# # 6. avg-daily-driving-session
|
||||
# #taosc core dumped
|
||||
# tdSql.execute("create table random_measure2_1 (ts timestamp,ela float, name binary(40))")
|
||||
# tdSql.query("SELECT ts,diff(mv) AS difka FROM (SELECT ts,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name,ts interval(10m) fill(value,0)) GROUP BY name,ts;")
|
||||
|
@ -166,7 +166,7 @@ class TDTestCase:
|
|||
# 7. avg-load
|
||||
tdSql.query("SELECT fleet, model,avg(ml) AS mean_load_percentage FROM (SELECT fleet, model,current_load/load_capacity AS ml FROM diagnostics partition BY name, fleet, model) partition BY fleet, model order by fleet ;")
|
||||
|
||||
# 8. daily-activity
|
||||
# 8. daily-activity
|
||||
tdSql.query(" SELECT model,ms1 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) fill(value,0)) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;")
|
||||
|
||||
tdSql.query(" SELECT model,ms1 FROM (SELECT _wstart as ts1,model, fleet,avg(status) AS ms1 FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by model, fleet interval(10m) ) WHERE ts1 >= '2016-01-01T00:00:00Z' AND ts1 < '2016-01-05T00:00:01Z' AND ms1<1;")
|
||||
|
@ -184,7 +184,7 @@ class TDTestCase:
|
|||
|
||||
|
||||
tdSql.query(" SELECT model,state_changed,count(state_changed) FROM (SELECT model,diff(broken_down) AS state_changed FROM (SELECT _wstart,model,cast(cast(floor(2*(sum(nzs)/count(nzs))) as bool) as int) AS broken_down FROM (SELECT ts,model, cast(cast(status as bool) as int) AS nzs FROM diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' ) WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition BY model interval(10m)) partition BY model) where state_changed =1 partition BY model,state_changed ;")
|
||||
|
||||
|
||||
#it's already supported:
|
||||
# last-loc
|
||||
tdSql.query("SELECT last_row(ts),latitude,longitude,name,driver FROM readings WHERE fleet='South' and name IS NOT NULL partition BY name,driver order by name ;")
|
||||
|
@ -192,7 +192,7 @@ class TDTestCase:
|
|||
|
||||
#2. low-fuel
|
||||
tdSql.query("SELECT last_row(ts),name,driver,fuel_state,driver FROM diagnostics WHERE fuel_state <= 0.1 AND fleet = 'South' and name IS NOT NULL GROUP BY name,driver order by name;")
|
||||
|
||||
|
||||
# 3. avg-vs-projected-fuel-consumption
|
||||
tdSql.query("select avg(fuel_consumption) as avg_fuel_consumption,avg(nominal_fuel_consumption) as nominal_fuel_consumption from readings where velocity > 1 group by fleet")
|
||||
|
||||
|
@ -213,16 +213,16 @@ class TDTestCase:
|
|||
'ctbPrefix': 'ctb',
|
||||
'ctbNum': 1,
|
||||
}
|
||||
|
||||
|
||||
dnodeNumbers=int(dnodeNumbers)
|
||||
mnodeNums=int(mnodeNums)
|
||||
vnodeNumbers = int(dnodeNumbers-mnodeNums)
|
||||
|
||||
|
||||
tdSql.query("select * from information_schema.ins_dnodes;")
|
||||
tdLog.debug(tdSql.queryResult)
|
||||
clusterComCheck.checkDnodes(dnodeNumbers)
|
||||
|
||||
tdLog.info("create database and stable")
|
||||
tdLog.info("create database and stable")
|
||||
tdDnodes=cluster.dnodes
|
||||
stopcount =0
|
||||
threads=[]
|
||||
|
@ -234,7 +234,7 @@ class TDTestCase:
|
|||
for tr in threads:
|
||||
tr.start()
|
||||
|
||||
tdLog.info("Take turns stopping %s "%stopRole)
|
||||
tdLog.info("Take turns stopping %s "%stopRole)
|
||||
while stopcount < restartNumbers:
|
||||
tdLog.info(" restart loop: %d"%stopcount )
|
||||
if stopRole == "mnode":
|
||||
|
@ -242,7 +242,7 @@ class TDTestCase:
|
|||
tdDnodes[i].stoptaosd()
|
||||
# sleep(10)
|
||||
tdDnodes[i].starttaosd()
|
||||
# sleep(10)
|
||||
# sleep(10)
|
||||
elif stopRole == "vnode":
|
||||
for i in range(vnodeNumbers):
|
||||
tdDnodes[i+mnodeNums].stoptaosd()
|
||||
|
@ -254,7 +254,7 @@ class TDTestCase:
|
|||
tdDnodes[i].stoptaosd()
|
||||
# sleep(10)
|
||||
tdDnodes[i].starttaosd()
|
||||
# sleep(10)
|
||||
# sleep(10)
|
||||
|
||||
# dnodeNumbers don't include database of schema
|
||||
if clusterComCheck.checkDnodes(dnodeNumbers):
|
||||
|
@ -265,12 +265,12 @@ class TDTestCase:
|
|||
tdLog.exit("one or more of dnodes failed to start ")
|
||||
# self.check3mnode()
|
||||
stopcount+=1
|
||||
|
||||
|
||||
for tr in threads:
|
||||
tr.join()
|
||||
|
||||
|
||||
def run(self):
|
||||
def run(self):
|
||||
tdLog.printNoPrefix("==========step1:create database and table,insert data ==============")
|
||||
self.createCluster()
|
||||
self.prepareData()
|
||||
|
|
|
@ -19,7 +19,7 @@ class TDTestCase:
|
|||
def init(self, conn, logSql):
|
||||
## add for TD-6672
|
||||
tdLog.debug("start to execute %s" % __file__)
|
||||
tdSql.init(conn.cursor(), logSql)
|
||||
tdSql.init(conn.cursor(), False)
|
||||
|
||||
def insertData(self, tb_name):
|
||||
insert_sql_list = [f'insert into {tb_name} values ("2021-01-01 12:00:00", 1, 1, 1, 3, 1.1, 1.1, "binary", "nchar", true, 1, 2, 3, 4)',
|
||||
|
@ -37,17 +37,17 @@ class TDTestCase:
|
|||
for sql in insert_sql_list:
|
||||
tdSql.execute(sql)
|
||||
|
||||
def initTb(self):
|
||||
tdCom.cleanTb()
|
||||
tb_name = tdCom.getLongName(8, "letters")
|
||||
def initTb(self, dbname="db"):
|
||||
tdCom.cleanTb(dbname)
|
||||
tb_name = f'{dbname}.{tdCom.getLongName(8, "letters")}'
|
||||
tdSql.execute(
|
||||
f"CREATE TABLE {tb_name} (ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, c7 binary(100), c8 nchar(200), c9 bool, c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned)")
|
||||
self.insertData(tb_name)
|
||||
return tb_name
|
||||
|
||||
def initStb(self, count=5):
|
||||
tdCom.cleanTb()
|
||||
tb_name = tdCom.getLongName(8, "letters")
|
||||
def initStb(self, count=5, dbname="db"):
|
||||
tdCom.cleanTb(dbname)
|
||||
tb_name = f'{dbname}.{tdCom.getLongName(8, "letters")}'
|
||||
tdSql.execute(
|
||||
f"CREATE TABLE {tb_name} (ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, c7 binary(100), c8 nchar(200), c9 bool, c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) tags (t1 tinyint, t2 smallint, t3 int, t4 bigint, t5 float, t6 double, t7 binary(100), t8 nchar(200), t9 bool, t10 tinyint unsigned, t11 smallint unsigned, t12 int unsigned, t13 bigint unsigned)")
|
||||
for i in range(1, count+1):
|
||||
|
@ -56,9 +56,10 @@ class TDTestCase:
|
|||
self.insertData(f'{tb_name}_sub_{i}')
|
||||
return tb_name
|
||||
|
||||
def initTwoStb(self):
|
||||
tdCom.cleanTb()
|
||||
tb_name = tdCom.getLongName(8, "letters")
|
||||
def initTwoStb(self, dbname="db"):
|
||||
tdCom.cleanTb(dbname)
|
||||
tb_name = f'{dbname}.{tdCom.getLongName(8, "letters")}'
|
||||
# tb_name = tdCom.getLongName(8, "letters")
|
||||
tb_name1 = f'{tb_name}1'
|
||||
tb_name2 = f'{tb_name}2'
|
||||
tdSql.execute(
|
||||
|
|
|
@ -8,49 +8,46 @@ from util.sql import *
|
|||
from util.cases import *
|
||||
|
||||
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):
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
tdSql.init(conn.cursor())
|
||||
|
||||
def prepare_datas(self):
|
||||
def prepare_datas(self, dbname="db"):
|
||||
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)
|
||||
tags (t1 int)
|
||||
'''
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
'''
|
||||
create table t1
|
||||
f'''
|
||||
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)
|
||||
'''
|
||||
)
|
||||
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):
|
||||
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(
|
||||
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("insert into 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("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()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )")
|
||||
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(f"insert into {dbname}.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()+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("insert into 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()-810d, 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(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
|
||||
f'''insert into {dbname}.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 )
|
||||
|
@ -94,68 +91,68 @@ class TDTestCase:
|
|||
else:
|
||||
tdLog.info("round value check pass , it work as expected ,sql is \"%s\" "%round_query )
|
||||
|
||||
def test_errors(self):
|
||||
def test_errors(self, dbname="db"):
|
||||
error_sql_lists = [
|
||||
"select round from t1",
|
||||
# "select round(-+--+c1) from t1",
|
||||
# "select +-round(c1) from t1",
|
||||
# "select ++-round(c1) from t1",
|
||||
# "select ++--round(c1) from t1",
|
||||
# "select - -round(c1)*0 from t1",
|
||||
# "select round(tbname+1) from t1 ",
|
||||
"select round(123--123)==1 from t1",
|
||||
"select round(c1) as 'd1' from t1",
|
||||
"select round(c1 ,c2 ) from t1",
|
||||
"select round(c1 ,NULL) from t1",
|
||||
"select round(,) from t1;",
|
||||
"select round(round(c1) ab from t1)",
|
||||
"select round(c1) as int from t1",
|
||||
"select round from stb1",
|
||||
# "select round(-+--+c1) from stb1",
|
||||
# "select +-round(c1) from stb1",
|
||||
# "select ++-round(c1) from stb1",
|
||||
# "select ++--round(c1) from stb1",
|
||||
# "select - -round(c1)*0 from stb1",
|
||||
# "select round(tbname+1) from stb1 ",
|
||||
"select round(123--123)==1 from stb1",
|
||||
"select round(c1) as 'd1' from stb1",
|
||||
"select round(c1 ,c2 ) from stb1",
|
||||
"select round(c1 ,NULL) from stb1",
|
||||
"select round(,) from stb1;",
|
||||
"select round(round(c1) ab from stb1)",
|
||||
"select round(c1) as int from stb1"
|
||||
f"select round from {dbname}.t1",
|
||||
# f"select round(-+--+c1) from {dbname}.t1",
|
||||
# f"select +-round(c1) from {dbname}.t1",
|
||||
# f"select ++-round(c1) from {dbname}.t1",
|
||||
# f"select ++--round(c1) from {dbname}.t1",
|
||||
# f"select - -round(c1)*0 from {dbname}.t1",
|
||||
# f"select round(tbname+1) from {dbname}.t1 ",
|
||||
f"select round(123--123)==1 from {dbname}.t1",
|
||||
f"select round(c1) as 'd1' from {dbname}.t1",
|
||||
f"select round(c1 ,c2 ) from {dbname}.t1",
|
||||
f"select round(c1 ,NULL) from {dbname}.t1",
|
||||
f"select round(,) from {dbname}.t1;",
|
||||
f"select round(round(c1) ab from {dbname}.t1)",
|
||||
f"select round(c1) as int from {dbname}.t1",
|
||||
f"select round from {dbname}.stb1",
|
||||
# f"select round(-+--+c1) from {dbname}.stb1",
|
||||
# f"select +-round(c1) from {dbname}.stb1",
|
||||
# f"select ++-round(c1) from {dbname}.stb1",
|
||||
# f"select ++--round(c1) from {dbname}.stb1",
|
||||
# f"select - -round(c1)*0 from {dbname}.stb1",
|
||||
# f"select round(tbname+1) from {dbname}.stb1 ",
|
||||
f"select round(123--123)==1 from {dbname}.stb1",
|
||||
f"select round(c1) as 'd1' from {dbname}.stb1",
|
||||
f"select round(c1 ,c2 ) from {dbname}.stb1",
|
||||
f"select round(c1 ,NULL) from {dbname}.stb1",
|
||||
f"select round(,) from {dbname}.stb1;",
|
||||
f"select round(round(c1) ab from {dbname}.stb1)",
|
||||
f"select round(c1) as int from {dbname}.stb1"
|
||||
]
|
||||
for error_sql in error_sql_lists:
|
||||
tdSql.error(error_sql)
|
||||
|
||||
def support_types(self):
|
||||
def support_types(self, dbname="db"):
|
||||
type_error_sql_lists = [
|
||||
"select round(ts) from t1" ,
|
||||
"select round(c7) from t1",
|
||||
"select round(c8) from t1",
|
||||
"select round(c9) from t1",
|
||||
"select round(ts) from ct1" ,
|
||||
"select round(c7) from ct1",
|
||||
"select round(c8) from ct1",
|
||||
"select round(c9) from ct1",
|
||||
"select round(ts) from ct3" ,
|
||||
"select round(c7) from ct3",
|
||||
"select round(c8) from ct3",
|
||||
"select round(c9) from ct3",
|
||||
"select round(ts) from ct4" ,
|
||||
"select round(c7) from ct4",
|
||||
"select round(c8) from ct4",
|
||||
"select round(c9) from ct4",
|
||||
"select round(ts) from stb1" ,
|
||||
"select round(c7) from stb1",
|
||||
"select round(c8) from stb1",
|
||||
"select round(c9) from stb1" ,
|
||||
f"select round(ts) from {dbname}.t1" ,
|
||||
f"select round(c7) from {dbname}.t1",
|
||||
f"select round(c8) from {dbname}.t1",
|
||||
f"select round(c9) from {dbname}.t1",
|
||||
f"select round(ts) from {dbname}.ct1" ,
|
||||
f"select round(c7) from {dbname}.ct1",
|
||||
f"select round(c8) from {dbname}.ct1",
|
||||
f"select round(c9) from {dbname}.ct1",
|
||||
f"select round(ts) from {dbname}.ct3" ,
|
||||
f"select round(c7) from {dbname}.ct3",
|
||||
f"select round(c8) from {dbname}.ct3",
|
||||
f"select round(c9) from {dbname}.ct3",
|
||||
f"select round(ts) from {dbname}.ct4" ,
|
||||
f"select round(c7) from {dbname}.ct4",
|
||||
f"select round(c8) from {dbname}.ct4",
|
||||
f"select round(c9) from {dbname}.ct4",
|
||||
f"select round(ts) from {dbname}.stb1" ,
|
||||
f"select round(c7) from {dbname}.stb1",
|
||||
f"select round(c8) from {dbname}.stb1",
|
||||
f"select round(c9) from {dbname}.stb1" ,
|
||||
|
||||
"select round(ts) from stbbb1" ,
|
||||
"select round(c7) from stbbb1",
|
||||
f"select round(ts) from {dbname}.stbbb1" ,
|
||||
f"select round(c7) from {dbname}.stbbb1",
|
||||
|
||||
"select round(ts) from tbname",
|
||||
"select round(c9) from tbname"
|
||||
f"select round(ts) from {dbname}.tbname",
|
||||
f"select round(c9) from {dbname}.tbname"
|
||||
|
||||
]
|
||||
|
||||
|
@ -164,127 +161,127 @@ class TDTestCase:
|
|||
|
||||
|
||||
type_sql_lists = [
|
||||
"select round(c1) from t1",
|
||||
"select round(c2) from t1",
|
||||
"select round(c3) from t1",
|
||||
"select round(c4) from t1",
|
||||
"select round(c5) from t1",
|
||||
"select round(c6) from t1",
|
||||
f"select round(c1) from {dbname}.t1",
|
||||
f"select round(c2) from {dbname}.t1",
|
||||
f"select round(c3) from {dbname}.t1",
|
||||
f"select round(c4) from {dbname}.t1",
|
||||
f"select round(c5) from {dbname}.t1",
|
||||
f"select round(c6) from {dbname}.t1",
|
||||
|
||||
"select round(c1) from ct1",
|
||||
"select round(c2) from ct1",
|
||||
"select round(c3) from ct1",
|
||||
"select round(c4) from ct1",
|
||||
"select round(c5) from ct1",
|
||||
"select round(c6) from ct1",
|
||||
f"select round(c1) from {dbname}.ct1",
|
||||
f"select round(c2) from {dbname}.ct1",
|
||||
f"select round(c3) from {dbname}.ct1",
|
||||
f"select round(c4) from {dbname}.ct1",
|
||||
f"select round(c5) from {dbname}.ct1",
|
||||
f"select round(c6) from {dbname}.ct1",
|
||||
|
||||
"select round(c1) from ct3",
|
||||
"select round(c2) from ct3",
|
||||
"select round(c3) from ct3",
|
||||
"select round(c4) from ct3",
|
||||
"select round(c5) from ct3",
|
||||
"select round(c6) from ct3",
|
||||
f"select round(c1) from {dbname}.ct3",
|
||||
f"select round(c2) from {dbname}.ct3",
|
||||
f"select round(c3) from {dbname}.ct3",
|
||||
f"select round(c4) from {dbname}.ct3",
|
||||
f"select round(c5) from {dbname}.ct3",
|
||||
f"select round(c6) from {dbname}.ct3",
|
||||
|
||||
"select round(c1) from stb1",
|
||||
"select round(c2) from stb1",
|
||||
"select round(c3) from stb1",
|
||||
"select round(c4) from stb1",
|
||||
"select round(c5) from stb1",
|
||||
"select round(c6) from stb1",
|
||||
f"select round(c1) from {dbname}.stb1",
|
||||
f"select round(c2) from {dbname}.stb1",
|
||||
f"select round(c3) from {dbname}.stb1",
|
||||
f"select round(c4) from {dbname}.stb1",
|
||||
f"select round(c5) from {dbname}.stb1",
|
||||
f"select round(c6) from {dbname}.stb1",
|
||||
|
||||
"select round(c6) as alisb from stb1",
|
||||
"select round(c6) alisb from stb1",
|
||||
f"select round(c6) as alisb from {dbname}.stb1",
|
||||
f"select round(c6) alisb from {dbname}.stb1",
|
||||
]
|
||||
|
||||
for type_sql in type_sql_lists:
|
||||
tdSql.query(type_sql)
|
||||
|
||||
def basic_round_function(self):
|
||||
def basic_round_function(self, dbname="db"):
|
||||
|
||||
# basic query
|
||||
tdSql.query("select c1 from ct3")
|
||||
tdSql.query(f"select c1 from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select c1 from t1")
|
||||
tdSql.query(f"select c1 from {dbname}.t1")
|
||||
tdSql.checkRows(12)
|
||||
tdSql.query("select c1 from stb1")
|
||||
tdSql.query(f"select c1 from {dbname}.stb1")
|
||||
tdSql.checkRows(25)
|
||||
|
||||
# used for empty table , ct3 is empty
|
||||
tdSql.query("select round(c1) from ct3")
|
||||
tdSql.query(f"select round(c1) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select round(c2) from ct3")
|
||||
tdSql.query(f"select round(c2) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select round(c3) from ct3")
|
||||
tdSql.query(f"select round(c3) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select round(c4) from ct3")
|
||||
tdSql.query(f"select round(c4) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select round(c5) from ct3")
|
||||
tdSql.query(f"select round(c5) from {dbname}.ct3")
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select round(c6) from ct3")
|
||||
tdSql.query(f"select round(c6) from {dbname}.ct3")
|
||||
|
||||
# used for regular table
|
||||
tdSql.query("select round(c1) from t1")
|
||||
tdSql.query(f"select round(c1) from {dbname}.t1")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(1 , 0, 1)
|
||||
tdSql.checkData(3 , 0, 3)
|
||||
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(3, 3, 33)
|
||||
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(3, 4, 33)
|
||||
tdSql.checkData(5, 5, None)
|
||||
|
||||
self.check_result_auto( "select c1, c2, c3 , c4, c5 from t1", "select (c1), round(c2) ,round(c3), round(c4), round(c5) from t1")
|
||||
self.check_result_auto( f"select c1, c2, c3 , c4, c5 from {dbname}.t1", f"select (c1), round(c2) ,round(c3), round(c4), round(c5) from {dbname}.t1")
|
||||
|
||||
# used for sub table
|
||||
tdSql.query("select round(c1) from ct1")
|
||||
tdSql.query(f"select round(c1) from {dbname}.ct1")
|
||||
tdSql.checkData(0, 0, 8)
|
||||
tdSql.checkData(1 , 0, 7)
|
||||
tdSql.checkData(3 , 0, 5)
|
||||
tdSql.checkData(5 , 0, 4)
|
||||
|
||||
tdSql.query("select round(c1) from ct1")
|
||||
self.check_result_auto( "select c1, c2, c3 , c4, c5 from ct1", "select (c1), round(c2) ,round(c3), round(c4), round(c5) from ct1")
|
||||
self.check_result_auto("select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from ct1;","select c1 from ct1" )
|
||||
tdSql.query(f"select round(c1) from {dbname}.ct1")
|
||||
self.check_result_auto( f"select c1, c2, c3 , c4, c5 from {dbname}.ct1", f"select (c1), round(c2) ,round(c3), round(c4), round(c5) from {dbname}.ct1")
|
||||
self.check_result_auto(f"select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from {dbname}.ct1;",f"select c1 from {dbname}.ct1" )
|
||||
|
||||
# used for stable table
|
||||
|
||||
tdSql.query("select round(c1) from stb1")
|
||||
tdSql.query(f"select round(c1) from {dbname}.stb1")
|
||||
tdSql.checkRows(25)
|
||||
self.check_result_auto( "select c1, c2, c3 , c4, c5 from ct4 ", "select (c1), round(c2) ,round(c3), round(c4), round(c5) from ct4")
|
||||
self.check_result_auto("select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from ct4;" , "select c1 from ct4" )
|
||||
self.check_result_auto( f"select c1, c2, c3 , c4, c5 from {dbname}.ct4 ", f"select (c1), round(c2) ,round(c3), round(c4), round(c5) from {dbname}.ct4")
|
||||
self.check_result_auto(f"select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from {dbname}.ct4;" , f"select c1 from {dbname}.ct4" )
|
||||
|
||||
|
||||
# used for not exists table
|
||||
tdSql.error("select round(c1) from stbbb1")
|
||||
tdSql.error("select round(c1) from tbname")
|
||||
tdSql.error("select round(c1) from ct5")
|
||||
tdSql.error(f"select round(c1) from {dbname}.stbbb1")
|
||||
tdSql.error(f"select round(c1) from {dbname}.tbname")
|
||||
tdSql.error(f"select round(c1) from {dbname}.ct5")
|
||||
|
||||
# mix with common col
|
||||
tdSql.query("select c1, round(c1) from ct1")
|
||||
tdSql.query(f"select c1, round(c1) from {dbname}.ct1")
|
||||
tdSql.checkData(0 , 0 ,8)
|
||||
tdSql.checkData(0 , 1 ,8)
|
||||
tdSql.checkData(4 , 0 ,0)
|
||||
tdSql.checkData(4 , 1 ,0)
|
||||
tdSql.query("select c1, round(c1) from ct4")
|
||||
tdSql.query(f"select c1, round(c1) from {dbname}.ct4")
|
||||
tdSql.checkData(0 , 0 , None)
|
||||
tdSql.checkData(0 , 1 ,None)
|
||||
tdSql.checkData(4 , 0 ,5)
|
||||
tdSql.checkData(4 , 1 ,5)
|
||||
tdSql.checkData(5 , 0 ,None)
|
||||
tdSql.checkData(5 , 1 ,None)
|
||||
tdSql.query("select c1, round(c1) from ct4 ")
|
||||
tdSql.query(f"select c1, round(c1) from {dbname}.ct4 ")
|
||||
tdSql.checkData(0 , 0 ,None)
|
||||
tdSql.checkData(0 , 1 ,None)
|
||||
tdSql.checkData(4 , 0 ,5)
|
||||
tdSql.checkData(4 , 1 ,5)
|
||||
|
||||
# mix with common functions
|
||||
tdSql.query("select c1, round(c1),c5, round(c5) from ct4 ")
|
||||
tdSql.query(f"select c1, round(c1),c5, round(c5) from {dbname}.ct4 ")
|
||||
tdSql.checkData(0 , 0 ,None)
|
||||
tdSql.checkData(0 , 1 ,None)
|
||||
tdSql.checkData(0 , 2 ,None)
|
||||
|
@ -300,34 +297,34 @@ class TDTestCase:
|
|||
tdSql.checkData(6 , 2 ,4.44000)
|
||||
tdSql.checkData(6 , 3 ,4.00000)
|
||||
|
||||
tdSql.query("select c1, round(c1),c5, round(c5) from stb1 ")
|
||||
tdSql.query(f"select c1, round(c1),c5, round(c5) from {dbname}.stb1 ")
|
||||
|
||||
# mix with agg functions , not support
|
||||
tdSql.error("select c1, round(c1),c5, count(c5) from stb1 ")
|
||||
tdSql.error("select c1, round(c1),c5, count(c5) from ct1 ")
|
||||
tdSql.error("select round(c1), count(c5) from stb1 ")
|
||||
tdSql.error("select round(c1), count(c5) from ct1 ")
|
||||
tdSql.error("select c1, count(c5) from ct1 ")
|
||||
tdSql.error("select c1, count(c5) from stb1 ")
|
||||
tdSql.error(f"select c1, round(c1),c5, count(c5) from {dbname}.stb1 ")
|
||||
tdSql.error(f"select c1, round(c1),c5, count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select round(c1), count(c5) from {dbname}.stb1 ")
|
||||
tdSql.error(f"select round(c1), count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select c1, count(c5) from {dbname}.ct1 ")
|
||||
tdSql.error(f"select c1, count(c5) from {dbname}.stb1 ")
|
||||
|
||||
# agg functions mix with agg functions
|
||||
|
||||
tdSql.query("select max(c5), count(c5) from stb1")
|
||||
tdSql.query("select max(c5), count(c5) from ct1")
|
||||
tdSql.query(f"select max(c5), count(c5) from {dbname}.stb1")
|
||||
tdSql.query(f"select max(c5), count(c5) from {dbname}.ct1")
|
||||
|
||||
|
||||
# bug fix for count
|
||||
tdSql.query("select count(c1) from ct4 ")
|
||||
tdSql.query(f"select count(c1) from {dbname}.ct4 ")
|
||||
tdSql.checkData(0,0,9)
|
||||
tdSql.query("select count(*) from ct4 ")
|
||||
tdSql.query(f"select count(*) from {dbname}.ct4 ")
|
||||
tdSql.checkData(0,0,12)
|
||||
tdSql.query("select count(c1) from stb1 ")
|
||||
tdSql.query(f"select count(c1) from {dbname}.stb1 ")
|
||||
tdSql.checkData(0,0,22)
|
||||
tdSql.query("select count(*) from stb1 ")
|
||||
tdSql.query(f"select count(*) from {dbname}.stb1 ")
|
||||
tdSql.checkData(0,0,25)
|
||||
|
||||
# bug fix for compute
|
||||
tdSql.query("select c1, abs(c1) -0 ,round(c1)-0 from ct4 ")
|
||||
tdSql.query(f"select c1, abs(c1) -0 ,round(c1)-0 from {dbname}.ct4 ")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(0, 2, None)
|
||||
|
@ -335,7 +332,7 @@ class TDTestCase:
|
|||
tdSql.checkData(1, 1, 8.000000000)
|
||||
tdSql.checkData(1, 2, 8.000000000)
|
||||
|
||||
tdSql.query(" select c1, abs(c1) -0 ,round(c1-0.1)-0.1 from ct4")
|
||||
tdSql.query(f"select c1, abs(c1) -0 ,round(c1-0.1)-0.1 from {dbname}.ct4")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(0, 2, None)
|
||||
|
@ -343,9 +340,8 @@ class TDTestCase:
|
|||
tdSql.checkData(1, 1, 8.000000000)
|
||||
tdSql.checkData(1, 2, 7.900000000)
|
||||
|
||||
def abs_func_filter(self):
|
||||
tdSql.execute("use db")
|
||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1>5 ")
|
||||
def abs_func_filter(self, dbname="db"):
|
||||
tdSql.query(f"select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from {dbname}.ct4 where c1>5 ")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkData(0,0,8)
|
||||
tdSql.checkData(0,1,8.000000000)
|
||||
|
@ -353,7 +349,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0,3,7.900000000)
|
||||
tdSql.checkData(0,4,3.000000000)
|
||||
|
||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-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(log(c1,2)-0.5) from {dbname}.ct4 where c1=5 ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,5)
|
||||
tdSql.checkData(0,1,5.000000000)
|
||||
|
@ -361,7 +357,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0,3,4.900000000)
|
||||
tdSql.checkData(0,4,2.000000000)
|
||||
|
||||
tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-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(log(c1,2)-0.5) from {dbname}.ct4 where c1=5 ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,5)
|
||||
tdSql.checkData(0,1,5.000000000)
|
||||
|
@ -369,7 +365,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0,3,4.900000000)
|
||||
tdSql.checkData(0,4,2.000000000)
|
||||
|
||||
tdSql.query("select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) , round(abs(c1))-0.5 from ct4 where c1>log(c1,2) limit 1 ")
|
||||
tdSql.query(f"select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) , round(abs(c1))-0.5 from {dbname}.ct4 where c1>log(c1,2) limit 1 ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,8)
|
||||
tdSql.checkData(0,1,88888)
|
||||
|
@ -382,44 +378,42 @@ class TDTestCase:
|
|||
def round_Arithmetic(self):
|
||||
pass
|
||||
|
||||
def check_boundary_values(self):
|
||||
def check_boundary_values(self, dbname="bound_test"):
|
||||
|
||||
tdSql.execute("drop database if exists bound_test")
|
||||
tdSql.execute("create database if not exists bound_test")
|
||||
time.sleep(3)
|
||||
tdSql.execute("use bound_test")
|
||||
tdSql.execute(f"drop database if exists {dbname}")
|
||||
tdSql.execute(f"create database if not exists {dbname}")
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
f"insert into sub1_bound values ( now(), 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now(), 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
|
||||
tdSql.execute(
|
||||
f"insert into sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
)
|
||||
|
||||
tdSql.error(
|
||||
f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
|
||||
f"insert into {dbname}.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( "select c1, c2, c3 , c4, c5 ,c6 from sub1_bound ", "select round(c1), round(c2) ,round(c3), round(c4), round(c5) ,round(c6) from sub1_bound")
|
||||
self.check_result_auto( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select round(c1), round(c2) ,round(c3), round(c3), round(c2) ,round(c1) from sub1_bound")
|
||||
self.check_result_auto("select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from sub1_bound;" , "select round(c1) from sub1_bound" )
|
||||
self.check_result_auto( f"select c1, c2, c3 , c4, c5 ,c6 from {dbname}.sub1_bound ", f"select round(c1), round(c2) ,round(c3), round(c4), round(c5) ,round(c6) from {dbname}.sub1_bound")
|
||||
self.check_result_auto( f"select c1, c2, c3 , c3, c2 ,c1 from {dbname}.sub1_bound ", f"select round(c1), round(c2) ,round(c3), round(c3), round(c2) ,round(c1) from {dbname}.sub1_bound")
|
||||
self.check_result_auto(f"select round(round(round(round(round(round(round(round(round(round(c1)))))))))) nest_col_func from {dbname}.sub1_bound;" , f"select round(c1) from {dbname}.sub1_bound" )
|
||||
|
||||
# check basic elem for table per row
|
||||
tdSql.query("select round(c1+0.2) ,round(c2) , round(c3+0.3) , round(c4-0.3), round(c5/2), round(c6/2) from sub1_bound ")
|
||||
tdSql.query(f"select round(c1+0.2) ,round(c2) , round(c3+0.3) , round(c4-0.3), round(c5/2), round(c6/2) from {dbname}.sub1_bound ")
|
||||
tdSql.checkData(0, 0, 2147483647.000000000)
|
||||
tdSql.checkData(0, 2, 32767.000000000)
|
||||
tdSql.checkData(0, 3, 127.000000000)
|
||||
|
@ -430,19 +424,18 @@ class TDTestCase:
|
|||
tdSql.checkData(4, 3, -123.000000000)
|
||||
tdSql.checkData(4, 4, -169499995645668991474575059260979281920.000000000)
|
||||
|
||||
self.check_result_auto("select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from sub1_bound" ,"select round(c1+1) ,round(c2) , round(c3*1) , round(c4/2), round(c5)/2, round(c6) from sub1_bound ")
|
||||
self.check_result_auto(f"select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from {dbname}.sub1_bound" ,f"select round(c1+1) ,round(c2) , round(c3*1) , round(c4/2), round(c5)/2, round(c6) from {dbname}.sub1_bound ")
|
||||
|
||||
def support_super_table_test(self):
|
||||
tdSql.execute(" use db ")
|
||||
self.check_result_auto( " select c5 from stb1 order by ts " , "select round(c5) from stb1 order by ts" )
|
||||
self.check_result_auto( " select c5 from stb1 order by tbname " , "select round(c5) from stb1 order by tbname" )
|
||||
self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select round(c5) from stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto( " select c5 from stb1 where c1 > 0 order by tbname " , "select round(c5) from stb1 where c1 > 0 order by tbname" )
|
||||
def support_super_table_test(self, dbname="db"):
|
||||
self.check_result_auto( f"select c5 from {dbname}.stb1 order by ts " , f"select round(c5) from {dbname}.stb1 order by ts" )
|
||||
self.check_result_auto( f"select c5 from {dbname}.stb1 order by tbname " , f"select round(c5) from {dbname}.stb1 order by tbname" )
|
||||
self.check_result_auto( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select round(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto( f"select c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select round(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
|
||||
self.check_result_auto( " select t1,c5 from stb1 order by ts " , "select round(t1), round(c5) from stb1 order by ts" )
|
||||
self.check_result_auto( " select t1,c5 from stb1 order by tbname " , "select round(t1) ,round(c5) from stb1 order by tbname" )
|
||||
self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select round(t1) ,round(c5) from stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto( " select t1,c5 from stb1 where c1 > 0 order by tbname " , "select round(t1) , round(c5) from stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto( f"select t1,c5 from {dbname}.stb1 order by ts " , f"select round(t1), round(c5) from {dbname}.stb1 order by ts" )
|
||||
self.check_result_auto( f"select t1,c5 from {dbname}.stb1 order by tbname " , f"select round(t1) ,round(c5) from {dbname}.stb1 order by tbname" )
|
||||
self.check_result_auto( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select round(t1) ,round(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
self.check_result_auto( f"select t1,c5 from {dbname}.stb1 where c1 > 0 order by tbname " , f"select round(t1) , round(c5) from {dbname}.stb1 where c1 > 0 order by tbname" )
|
||||
pass
|
||||
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue