Merge branch '3.0' of https://github.com/taosdata/TDengine into 3.0
This commit is contained in:
commit
0975e37845
|
@ -1,6 +1,6 @@
|
||||||
# openssl
|
# openssl
|
||||||
ExternalProject_Add(openssl
|
ExternalProject_Add(openssl
|
||||||
URL https://www.openssl.org/source/openssl-3.1.3.tar.gz
|
URL https://github.com/openssl/openssl/releases/download/openssl-3.1.3/openssl-3.1.3.tar.gz
|
||||||
URL_HASH SHA256=f0316a2ebd89e7f2352976445458689f80302093788c466692fb2a188b2eacf6
|
URL_HASH SHA256=f0316a2ebd89e7f2352976445458689f80302093788c466692fb2a188b2eacf6
|
||||||
DOWNLOAD_NO_PROGRESS 1
|
DOWNLOAD_NO_PROGRESS 1
|
||||||
DOWNLOAD_DIR "${TD_CONTRIB_DIR}/deps-download"
|
DOWNLOAD_DIR "${TD_CONTRIB_DIR}/deps-download"
|
||||||
|
|
|
@ -67,7 +67,7 @@ If a stream is created with PARTITION BY clause and SUBTABLE clause, the name of
|
||||||
CREATE STREAM avg_vol_s INTO avg_vol SUBTABLE(CONCAT('new-', tname)) AS SELECT _wstart, count(*), avg(voltage) FROM meters PARTITION BY tbname tname INTERVAL(1m);
|
CREATE STREAM avg_vol_s INTO avg_vol SUBTABLE(CONCAT('new-', tname)) AS SELECT _wstart, count(*), avg(voltage) FROM meters PARTITION BY tbname tname INTERVAL(1m);
|
||||||
```
|
```
|
||||||
|
|
||||||
IN PARTITION clause, 'tbname', representing each subtable name of source supertable, is given alias 'tname'. And 'tname' is used in SUBTABLE clause. In SUBTABLE clause, each auto created subtable will concat 'new-' and source subtable name as their name. Other expressions are also allowed in SUBTABLE clause, but the output type must be varchar.
|
IN PARTITION clause, 'tbname', representing each subtable name of source supertable, is given alias 'tname'. And 'tname' is used in SUBTABLE clause. In SUBTABLE clause, each auto created subtable will concat 'new-' and source subtable name as their name(Starting from 3.2.3.0, in order to avoid the expression in subtable being unable to distinguish between different subtables, add '_groupId' to the end of subtable name).
|
||||||
|
|
||||||
If the output length exceeds the limitation of TDengine(192), the name will be truncated. If the generated name is occupied by some other table, the creation and writing of the new subtable will be failed.
|
If the output length exceeds the limitation of TDengine(192), the name will be truncated. If the generated name is occupied by some other table, the creation and writing of the new subtable will be failed.
|
||||||
|
|
||||||
|
|
|
@ -84,18 +84,22 @@ Schemaless writes process row data according to the following principles.
|
||||||
|
|
||||||
1. You can use the following rules to generate the subtable names: first, combine the measurement name and the key and value of the label into the next string:
|
1. You can use the following rules to generate the subtable names: first, combine the measurement name and the key and value of the label into the next string:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"measurement,tag_key1=tag_value1,tag_key2=tag_value2"
|
"measurement,tag_key1=tag_value1,tag_key2=tag_value2"
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
Note that tag_key1, tag_key2 are not the original order of the tags entered by the user but the result of using the tag names in ascending order of the strings. Therefore, tag_key1 is not the first tag entered in the line protocol.
|
Note that tag_key1, tag_key2 are not the original order of the tags entered by the user but the result of using the tag names in ascending order of the strings. Therefore, tag_key1 is not the first tag entered in the line protocol.
|
||||||
The string's MD5 hash value "md5_val" is calculated after the ranking is completed. The calculation result is then combined with the string to generate the table name: "t_md5_val". "t\_" is a fixed prefix that every table generated by this mapping relationship has.
|
The string's MD5 hash value "md5_val" is calculated after the ranking is completed. The calculation result is then combined with the string to generate the table name: "t_md5_val". "t\_" is a fixed prefix that every table generated by this mapping relationship has.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
If you do not want to use an automatically generated table name, there are two ways to specify sub table names, the first one has a higher priority.
|
If you do not want to use an automatically generated table name, there are two ways to specify sub table names(the first one has a higher priority).
|
||||||
You can configure smlAutoChildTableNameDelimiter in taos.cfg(except for `@ # space \r \t \n`), for example, `smlAutoChildTableNameDelimiter=tname`. You can insert `st,t0=cpul,t1=4 c1=3 1626006833639000000` and the table name will be cpu1-4.
|
|
||||||
You can configure smlChildTableName in taos.cfg to specify table names, for example, `smlChildTableName=tname`. You can insert `st,tname=cpul,t1=4 c1=3 1626006833639000000` and the cpu1 table will be automatically created. Note that if multiple rows have the same tname but different tag_set values, the tag_set of the first row is used to create the table and the others are ignored.
|
1. You can configure smlAutoChildTableNameDelimiter in taos.cfg(except for `@ # space \r \t \n`).
|
||||||
|
1. For example, `smlAutoChildTableNameDelimiter=tname`. You can insert `st,t0=cpul,t1=4 c1=3 1626006833639000000` and the table name will be cpu1-4.
|
||||||
|
|
||||||
|
2. You can configure smlChildTableName in taos.cfg to specify table names.
|
||||||
|
2. For example, `smlChildTableName=tname`. You can insert `st,tname=cpul,t1=4 c1=3 1626006833639000000` and the cpu1 table will be automatically created. Note that if multiple rows have the same tname but different tag_set values, the tag_set of the first row is used to create the table and the others are ignored.
|
||||||
|
|
||||||
2. If the super table obtained by parsing the line protocol does not exist, this super table is created.
|
2. If the super table obtained by parsing the line protocol does not exist, this super table is created.
|
||||||
**Important:** Manually creating supertables for schemaless writing is not supported. Schemaless writing creates appropriate supertables automatically.
|
**Important:** Manually creating supertables for schemaless writing is not supported. Schemaless writing creates appropriate supertables automatically.
|
||||||
|
|
|
@ -34,7 +34,7 @@ subquery: SELECT select_list
|
||||||
|
|
||||||
stb_name 是保存计算结果的超级表的表名,如果该超级表不存在,会自动创建;如果已存在,则检查列的schema信息。详见 写入已存在的超级表
|
stb_name 是保存计算结果的超级表的表名,如果该超级表不存在,会自动创建;如果已存在,则检查列的schema信息。详见 写入已存在的超级表
|
||||||
|
|
||||||
TAGS 字句定义了流计算中创建TAG的规则,可以为每个partition对应的子表生成自定义的TAG值,详见 自定义TAG
|
TAGS 子句定义了流计算中创建TAG的规则,可以为每个partition对应的子表生成自定义的TAG值,详见 自定义TAG
|
||||||
```sql
|
```sql
|
||||||
create_definition:
|
create_definition:
|
||||||
col_name column_definition
|
col_name column_definition
|
||||||
|
@ -77,7 +77,7 @@ SELECT _wstart, count(*), avg(voltage) FROM meters PARTITION BY tbname INTERVAL(
|
||||||
CREATE STREAM avg_vol_s INTO avg_vol SUBTABLE(CONCAT('new-', tname)) AS SELECT _wstart, count(*), avg(voltage) FROM meters PARTITION BY tbname tname INTERVAL(1m);
|
CREATE STREAM avg_vol_s INTO avg_vol SUBTABLE(CONCAT('new-', tname)) AS SELECT _wstart, count(*), avg(voltage) FROM meters PARTITION BY tbname tname INTERVAL(1m);
|
||||||
```
|
```
|
||||||
|
|
||||||
PARTITION 子句中,为 tbname 定义了一个别名 tname, 在PARTITION 子句中的别名可以用于 SUBTABLE 子句中的表达式计算,在上述示例中,流新创建的子表将以前缀 'new-' 连接原表名作为表名。
|
PARTITION 子句中,为 tbname 定义了一个别名 tname, 在PARTITION 子句中的别名可以用于 SUBTABLE 子句中的表达式计算,在上述示例中,流新创建的子表将以前缀 'new-' 连接原表名作为表名(从3.2.3.0开始,为了避免 sutable 中的表达式无法区分各个子表,即误将多个相同时间线写入一个子表,在指定的子表名后面加上 _groupId)。
|
||||||
|
|
||||||
注意,子表名的长度若超过 TDengine 的限制,将被截断。若要生成的子表名已经存在于另一超级表,由于 TDengine 的子表名是唯一的,因此对应新子表的创建以及数据的写入将会失败。
|
注意,子表名的长度若超过 TDengine 的限制,将被截断。若要生成的子表名已经存在于另一超级表,由于 TDengine 的子表名是唯一的,因此对应新子表的创建以及数据的写入将会失败。
|
||||||
|
|
||||||
|
@ -212,8 +212,8 @@ CREATE STREAM streams2 trigger at_once INTO st1 TAGS(cc varchar(100)) as select
|
||||||
PARTITION 子句中,为 concat("tag-", tbname)定义了一个别名cc, 对应超级表st1的自定义TAG的名字。在上述示例中,流新创建的子表的TAG将以前缀 'new-' 连接原表名作为TAG的值。
|
PARTITION 子句中,为 concat("tag-", tbname)定义了一个别名cc, 对应超级表st1的自定义TAG的名字。在上述示例中,流新创建的子表的TAG将以前缀 'new-' 连接原表名作为TAG的值。
|
||||||
|
|
||||||
会对TAG信息进行如下检查
|
会对TAG信息进行如下检查
|
||||||
1.检查tag的schema信息是否匹配,对于不匹配的,则自动进行数据类型转换,当前只有数据长度大于4096byte时才报错,其余场景都能进行类型转换。
|
1. 检查tag的schema信息是否匹配,对于不匹配的,则自动进行数据类型转换,当前只有数据长度大于4096byte时才报错,其余场景都能进行类型转换。
|
||||||
2.检查tag的个数是否相同,如果不同,需要显示的指定超级表与subquery的tag的对应关系,否则报错;如果相同,可以指定对应关系,也可以不指定,不指定则按位置顺序对应。
|
2. 检查tag的个数是否相同,如果不同,需要显示的指定超级表与subquery的tag的对应关系,否则报错;如果相同,可以指定对应关系,也可以不指定,不指定则按位置顺序对应。
|
||||||
|
|
||||||
## 清理中间状态
|
## 清理中间状态
|
||||||
|
|
||||||
|
|
|
@ -87,19 +87,20 @@ st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4f64 1626006833639000000
|
||||||
|
|
||||||
1. 将使用如下规则来生成子表名:首先将 measurement 的名称和标签的 key 和 value 组合成为如下的字符串
|
1. 将使用如下规则来生成子表名:首先将 measurement 的名称和标签的 key 和 value 组合成为如下的字符串
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"measurement,tag_key1=tag_value1,tag_key2=tag_value2"
|
"measurement,tag_key1=tag_value1,tag_key2=tag_value2"
|
||||||
```
|
```
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
需要注意的是,这里的 tag_key1, tag_key2 并不是用户输入的标签的原始顺序,而是使用了标签名称按照字符串升序排列后的结果。所以,tag_key1 并不是在行协议中输入的第一个标签。
|
需要注意的是,这里的 tag_key1, tag_key2 并不是用户输入的标签的原始顺序,而是使用了标签名称按照字符串升序排列后的结果。所以,tag_key1 并不是在行协议中输入的第一个标签。
|
||||||
排列完成以后计算该字符串的 MD5 散列值 "md5_val"。然后将计算的结果与字符串组合生成表名:“t_md5_val”。其中的 “t_” 是固定的前缀,每个通过该映射关系自动生成的表都具有该前缀。
|
排列完成以后计算该字符串的 MD5 散列值 "md5_val"。然后将计算的结果与字符串组合生成表名:“t_md5_val”。其中的 “t_” 是固定的前缀,每个通过该映射关系自动生成的表都具有该前缀。
|
||||||
:::tip
|
:::tip
|
||||||
如果不想用自动生成的表名,有两种指定子表名的方式,第一种优先级更高:
|
|
||||||
通过在taos.cfg里配置 smlAutoChildTableNameDelimiter 参数来指定(`@ # 空格 回车 换行 制表符`除外)。
|
如果不想用自动生成的表名,有两种指定子表名的方式(第一种优先级更高)。
|
||||||
举例如下:配置 smlAutoChildTableNameDelimiter=- 插入数据为 st,t0=cpu1,t1=4 c1=3 1626006833639000000 则创建的表名为 cpu1-4。
|
1. 通过在taos.cfg里配置 smlAutoChildTableNameDelimiter 参数来指定(`@ # 空格 回车 换行 制表符`除外)。
|
||||||
通过在taos.cfg里配置 smlChildTableName 参数来指定。
|
1. 举例如下:配置 smlAutoChildTableNameDelimiter=- 插入数据为 st,t0=cpu1,t1=4 c1=3 1626006833639000000 则创建的表名为 cpu1-4。
|
||||||
举例如下:配置 smlChildTableName=tname 插入数据为 st,tname=cpu1,t1=4 c1=3 1626006833639000000 则创建的表名为 cpu1,注意如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一行自动建表时指定的 tag_set,其他的行会忽略)。
|
2. 通过在taos.cfg里配置 smlChildTableName 参数来指定。
|
||||||
|
1. 举例如下:配置 smlChildTableName=tname 插入数据为 st,tname=cpu1,t1=4 c1=3 1626006833639000000 则创建的表名为 cpu1,注意如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一行自动建表时指定的 tag_set,其他的行会忽略。
|
||||||
|
|
||||||
2. 如果解析行协议获得的超级表不存在,则会创建这个超级表(不建议手动创建超级表,不然插入数据可能异常)。
|
2. 如果解析行协议获得的超级表不存在,则会创建这个超级表(不建议手动创建超级表,不然插入数据可能异常)。
|
||||||
3. 如果解析行协议获得子表不存在,则 Schemaless 会按照步骤 1 或 2 确定的子表名来创建子表。
|
3. 如果解析行协议获得子表不存在,则 Schemaless 会按照步骤 1 或 2 确定的子表名来创建子表。
|
||||||
|
|
|
@ -1978,6 +1978,14 @@ typedef struct {
|
||||||
char data[];
|
char data[];
|
||||||
} SRetrieveTableRsp;
|
} SRetrieveTableRsp;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int64_t version;
|
||||||
|
int64_t numOfRows;
|
||||||
|
int8_t compressed;
|
||||||
|
int8_t precision;
|
||||||
|
char data[];
|
||||||
|
} SRetrieveTableRspForTmq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t handle;
|
int64_t handle;
|
||||||
int64_t useconds;
|
int64_t useconds;
|
||||||
|
|
|
@ -150,7 +150,7 @@ int32_t smlBindData(SQuery* handle, bool dataFormat, SArray* tags, SArray* colsS
|
||||||
STableMeta* pTableMeta, char* tableName, const char* sTableName, int32_t sTableNameLen, int32_t ttl,
|
STableMeta* pTableMeta, char* tableName, const char* sTableName, int32_t sTableNameLen, int32_t ttl,
|
||||||
char* msgBuf, int32_t msgBufLen);
|
char* msgBuf, int32_t msgBufLen);
|
||||||
int32_t smlBuildOutput(SQuery* handle, SHashObj* pVgHash);
|
int32_t smlBuildOutput(SQuery* handle, SHashObj* pVgHash);
|
||||||
int rawBlockBindData(SQuery *query, STableMeta* pTableMeta, void* data, SVCreateTbReq* pCreateTb, TAOS_FIELD *fields, int numFields, bool needChangeLength);
|
int rawBlockBindData(SQuery *query, STableMeta* pTableMeta, void* data, SVCreateTbReq** pCreateTb, TAOS_FIELD *fields, int numFields, bool needChangeLength);
|
||||||
|
|
||||||
int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray);
|
int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray);
|
||||||
SArray* serializeVgroupsCreateTableBatch(SHashObj* pVgroupHashmap);
|
SArray* serializeVgroupsCreateTableBatch(SHashObj* pVgroupHashmap);
|
||||||
|
|
|
@ -521,6 +521,7 @@ int32_t* taosGetErrno();
|
||||||
#define TSDB_CODE_QRY_INVALID_INPUT TAOS_DEF_ERROR_CODE(0, 0x070F)
|
#define TSDB_CODE_QRY_INVALID_INPUT TAOS_DEF_ERROR_CODE(0, 0x070F)
|
||||||
// #define TSDB_CODE_QRY_INVALID_SCHEMA_VERSION TAOS_DEF_ERROR_CODE(0, 0x0710) // 2.x
|
// #define TSDB_CODE_QRY_INVALID_SCHEMA_VERSION TAOS_DEF_ERROR_CODE(0, 0x0710) // 2.x
|
||||||
// #define TSDB_CODE_QRY_RESULT_TOO_LARGE TAOS_DEF_ERROR_CODE(0, 0x0711) // 2.x
|
// #define TSDB_CODE_QRY_RESULT_TOO_LARGE TAOS_DEF_ERROR_CODE(0, 0x0711) // 2.x
|
||||||
|
#define TSDB_CODE_QRY_INVALID_WINDOW_CONDITION TAOS_DEF_ERROR_CODE(0, 0x0712)
|
||||||
#define TSDB_CODE_QRY_SCH_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0720)
|
#define TSDB_CODE_QRY_SCH_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0720)
|
||||||
#define TSDB_CODE_QRY_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0721)
|
#define TSDB_CODE_QRY_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0721)
|
||||||
#define TSDB_CODE_QRY_TASK_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0722)
|
#define TSDB_CODE_QRY_TASK_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0722)
|
||||||
|
|
|
@ -155,6 +155,7 @@ typedef struct STscObj {
|
||||||
int8_t biMode;
|
int8_t biMode;
|
||||||
int32_t acctId;
|
int32_t acctId;
|
||||||
uint32_t connId;
|
uint32_t connId;
|
||||||
|
int32_t appHbMgrIdx;
|
||||||
int64_t id; // ref ID returned by taosAddRef
|
int64_t id; // ref ID returned by taosAddRef
|
||||||
TdThreadMutex mutex; // used to protect the operation on db
|
TdThreadMutex mutex; // used to protect the operation on db
|
||||||
int32_t numOfReqs; // number of sqlObj bound to this connection
|
int32_t numOfReqs; // number of sqlObj bound to this connection
|
||||||
|
@ -298,6 +299,8 @@ void doSetOneRowPtr(SReqResultInfo* pResultInfo);
|
||||||
void setResPrecision(SReqResultInfo* pResInfo, int32_t precision);
|
void setResPrecision(SReqResultInfo* pResInfo, int32_t precision);
|
||||||
int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4,
|
int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4,
|
||||||
bool freeAfterUse);
|
bool freeAfterUse);
|
||||||
|
int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows,
|
||||||
|
bool convertUcs4);
|
||||||
void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols);
|
void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols);
|
||||||
void doFreeReqResultInfo(SReqResultInfo* pResInfo);
|
void doFreeReqResultInfo(SReqResultInfo* pResInfo);
|
||||||
int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, SArray** pReq);
|
int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, SArray** pReq);
|
||||||
|
|
|
@ -283,6 +283,7 @@ void *createTscObj(const char *user, const char *auth, const char *db, int32_t c
|
||||||
|
|
||||||
pObj->connType = connType;
|
pObj->connType = connType;
|
||||||
pObj->pAppInfo = pAppInfo;
|
pObj->pAppInfo = pAppInfo;
|
||||||
|
pObj->appHbMgrIdx = pAppInfo->pAppHbMgr->idx;
|
||||||
tstrncpy(pObj->user, user, sizeof(pObj->user));
|
tstrncpy(pObj->user, user, sizeof(pObj->user));
|
||||||
memcpy(pObj->pass, auth, TSDB_PASSWORD_LEN);
|
memcpy(pObj->pass, auth, TSDB_PASSWORD_LEN);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ typedef struct {
|
||||||
};
|
};
|
||||||
} SHbParam;
|
} SHbParam;
|
||||||
|
|
||||||
static SClientHbMgr clientHbMgr = {0};
|
SClientHbMgr clientHbMgr = {0};
|
||||||
|
|
||||||
static int32_t hbCreateThread();
|
static int32_t hbCreateThread();
|
||||||
static void hbStopThread();
|
static void hbStopThread();
|
||||||
|
@ -1294,9 +1294,8 @@ void hbMgrCleanUp() {
|
||||||
|
|
||||||
taosThreadMutexLock(&clientHbMgr.lock);
|
taosThreadMutexLock(&clientHbMgr.lock);
|
||||||
appHbMgrCleanup();
|
appHbMgrCleanup();
|
||||||
taosArrayDestroy(clientHbMgr.appHbMgrs);
|
clientHbMgr.appHbMgrs = taosArrayDestroy(clientHbMgr.appHbMgrs);
|
||||||
taosThreadMutexUnlock(&clientHbMgr.lock);
|
taosThreadMutexUnlock(&clientHbMgr.lock);
|
||||||
clientHbMgr.appHbMgrs = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, int64_t clusterId) {
|
int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, int64_t clusterId) {
|
||||||
|
@ -1335,19 +1334,18 @@ int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, in
|
||||||
}
|
}
|
||||||
|
|
||||||
void hbDeregisterConn(STscObj *pTscObj, SClientHbKey connKey) {
|
void hbDeregisterConn(STscObj *pTscObj, SClientHbKey connKey) {
|
||||||
SAppHbMgr *pAppHbMgr = pTscObj->pAppInfo->pAppHbMgr;
|
taosThreadMutexLock(&clientHbMgr.lock);
|
||||||
SClientHbReq *pReq = taosHashAcquire(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
|
SAppHbMgr *pAppHbMgr = taosArrayGetP(clientHbMgr.appHbMgrs, pTscObj->appHbMgrIdx);
|
||||||
if (pReq) {
|
if (pAppHbMgr) {
|
||||||
tFreeClientHbReq(pReq);
|
SClientHbReq *pReq = taosHashAcquire(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
|
||||||
taosHashRemove(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
|
if (pReq) {
|
||||||
taosHashRelease(pAppHbMgr->activeInfo, pReq);
|
tFreeClientHbReq(pReq);
|
||||||
|
taosHashRemove(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
|
||||||
|
taosHashRelease(pAppHbMgr->activeInfo, pReq);
|
||||||
|
atomic_sub_fetch_32(&pAppHbMgr->connKeyCnt, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
taosThreadMutexUnlock(&clientHbMgr.lock);
|
||||||
if (NULL == pReq) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
atomic_sub_fetch_32(&pAppHbMgr->connKeyCnt, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set heart beat thread quit mode , if quicByKill 1 then kill thread else quit from inner
|
// set heart beat thread quit mode , if quicByKill 1 then kill thread else quit from inner
|
||||||
|
|
|
@ -1795,6 +1795,7 @@ int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols) {
|
||||||
|
|
||||||
static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, int32_t numOfRows) {
|
static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, int32_t numOfRows) {
|
||||||
char* p = (char*)pResultInfo->pData;
|
char* p = (char*)pResultInfo->pData;
|
||||||
|
int32_t blockVersion = *(int32_t*)p;
|
||||||
|
|
||||||
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column
|
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column
|
||||||
// length |
|
// length |
|
||||||
|
@ -1810,7 +1811,7 @@ static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, i
|
||||||
|
|
||||||
char* pStart = p + len;
|
char* pStart = p + len;
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
int32_t colLen = htonl(colLength[i]);
|
int32_t colLen = (blockVersion == 1) ? htonl(colLength[i]) : colLength[i];
|
||||||
|
|
||||||
if (pResultInfo->fields[i].type == TSDB_DATA_TYPE_JSON) {
|
if (pResultInfo->fields[i].type == TSDB_DATA_TYPE_JSON) {
|
||||||
int32_t* offset = (int32_t*)pStart;
|
int32_t* offset = (int32_t*)pStart;
|
||||||
|
@ -1873,6 +1874,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
||||||
tscDebug("start to convert form json format string");
|
tscDebug("start to convert form json format string");
|
||||||
|
|
||||||
char* p = (char*)pResultInfo->pData;
|
char* p = (char*)pResultInfo->pData;
|
||||||
|
int32_t blockVersion = *(int32_t*)p;
|
||||||
int32_t dataLen = estimateJsonLen(pResultInfo, numOfCols, numOfRows);
|
int32_t dataLen = estimateJsonLen(pResultInfo, numOfCols, numOfRows);
|
||||||
if (dataLen <= 0) {
|
if (dataLen <= 0) {
|
||||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
|
@ -1908,8 +1910,8 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
||||||
char* pStart = p;
|
char* pStart = p;
|
||||||
char* pStart1 = p1;
|
char* pStart1 = p1;
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
int32_t colLen = htonl(colLength[i]);
|
int32_t colLen = (blockVersion == 1) ? htonl(colLength[i]) : colLength[i];
|
||||||
int32_t colLen1 = htonl(colLength1[i]);
|
int32_t colLen1 = (blockVersion == 1) ? htonl(colLength1[i]) : colLength1[i];
|
||||||
if (ASSERT(colLen < dataLen)) {
|
if (ASSERT(colLen < dataLen)) {
|
||||||
tscError("doConvertJson error: colLen:%d >= dataLen:%d", colLen, dataLen);
|
tscError("doConvertJson error: colLen:%d >= dataLen:%d", colLen, dataLen);
|
||||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
|
@ -1968,7 +1970,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
||||||
}
|
}
|
||||||
colLen1 = len;
|
colLen1 = len;
|
||||||
totalLen += colLen1;
|
totalLen += colLen1;
|
||||||
colLength1[i] = htonl(len);
|
colLength1[i] = (blockVersion == 1) ? htonl(len) : len;
|
||||||
} else if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
|
} else if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
|
||||||
len = numOfRows * sizeof(int32_t);
|
len = numOfRows * sizeof(int32_t);
|
||||||
memcpy(pStart1, pStart, len);
|
memcpy(pStart1, pStart, len);
|
||||||
|
@ -2057,7 +2059,9 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
|
||||||
|
|
||||||
char* pStart = p;
|
char* pStart = p;
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
colLength[i] = htonl(colLength[i]);
|
if(blockVersion == 1){
|
||||||
|
colLength[i] = htonl(colLength[i]);
|
||||||
|
}
|
||||||
if (colLength[i] >= dataLen) {
|
if (colLength[i] >= dataLen) {
|
||||||
tscError("invalid colLength %d, dataLen %d", colLength[i], dataLen);
|
tscError("invalid colLength %d, dataLen %d", colLength[i], dataLen);
|
||||||
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
return TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
#include "tversion.h"
|
#include "tversion.h"
|
||||||
|
|
||||||
|
extern SClientHbMgr clientHbMgr;
|
||||||
|
|
||||||
static void setErrno(SRequestObj* pRequest, int32_t code) {
|
static void setErrno(SRequestObj* pRequest, int32_t code) {
|
||||||
pRequest->code = code;
|
pRequest->code = code;
|
||||||
terrno = code;
|
terrno = code;
|
||||||
|
@ -63,8 +65,9 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
|
|
||||||
STscObj* pTscObj = pRequest->pTscObj;
|
STscObj* pTscObj = pRequest->pTscObj;
|
||||||
|
|
||||||
if (NULL == pTscObj->pAppInfo || NULL == pTscObj->pAppInfo->pAppHbMgr) {
|
if (NULL == pTscObj->pAppInfo) {
|
||||||
setErrno(pRequest, TSDB_CODE_TSC_DISCONNECTED);
|
code = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
|
setErrno(pRequest, code);
|
||||||
tsem_post(&pRequest->body.rspSem);
|
tsem_post(&pRequest->body.rspSem);
|
||||||
goto End;
|
goto End;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +98,8 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connectRsp.epSet.numOfEps == 0) {
|
if (connectRsp.epSet.numOfEps == 0) {
|
||||||
setErrno(pRequest, TSDB_CODE_APP_ERROR);
|
code = TSDB_CODE_APP_ERROR;
|
||||||
|
setErrno(pRequest, code);
|
||||||
tsem_post(&pRequest->body.rspSem);
|
tsem_post(&pRequest->body.rspSem);
|
||||||
goto End;
|
goto End;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +146,18 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
pTscObj->authVer = connectRsp.authVer;
|
pTscObj->authVer = connectRsp.authVer;
|
||||||
pTscObj->whiteListInfo.ver = connectRsp.whiteListVer;
|
pTscObj->whiteListInfo.ver = connectRsp.whiteListVer;
|
||||||
|
|
||||||
hbRegisterConn(pTscObj->pAppInfo->pAppHbMgr, pTscObj->id, connectRsp.clusterId, connectRsp.connType);
|
taosThreadMutexLock(&clientHbMgr.lock);
|
||||||
|
SAppHbMgr* pAppHbMgr = taosArrayGetP(clientHbMgr.appHbMgrs, pTscObj->appHbMgrIdx);
|
||||||
|
if (pAppHbMgr) {
|
||||||
|
hbRegisterConn(pAppHbMgr, pTscObj->id, connectRsp.clusterId, connectRsp.connType);
|
||||||
|
} else {
|
||||||
|
taosThreadMutexUnlock(&clientHbMgr.lock);
|
||||||
|
code = TSDB_CODE_TSC_DISCONNECTED;
|
||||||
|
setErrno(pRequest, code);
|
||||||
|
tsem_post(&pRequest->body.rspSem);
|
||||||
|
goto End;
|
||||||
|
}
|
||||||
|
taosThreadMutexUnlock(&clientHbMgr.lock);
|
||||||
|
|
||||||
tscDebug("0x%" PRIx64 " clusterId:%" PRId64 ", totalConn:%" PRId64, pRequest->requestId, connectRsp.clusterId,
|
tscDebug("0x%" PRIx64 " clusterId:%" PRId64 ", totalConn:%" PRId64, pRequest->requestId, connectRsp.clusterId,
|
||||||
pTscObj->pAppInfo->numOfConns);
|
pTscObj->pAppInfo->numOfConns);
|
||||||
|
|
|
@ -1553,6 +1553,18 @@ end:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void* getRawDataFromRes(void *pRetrieve){
|
||||||
|
void* rawData = NULL;
|
||||||
|
// deal with compatibility
|
||||||
|
if(*(int64_t*)pRetrieve == 0){
|
||||||
|
rawData = ((SRetrieveTableRsp*)pRetrieve)->data;
|
||||||
|
}else if(*(int64_t*)pRetrieve == 1){
|
||||||
|
rawData = ((SRetrieveTableRspForTmq*)pRetrieve)->data;
|
||||||
|
}
|
||||||
|
ASSERT(rawData != NULL);
|
||||||
|
return rawData;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
if(taos == NULL || data == NULL){
|
if(taos == NULL || data == NULL){
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
@ -1607,7 +1619,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
}
|
}
|
||||||
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||||
while (++rspObj.resIter < rspObj.rsp.blockNum) {
|
while (++rspObj.resIter < rspObj.rsp.blockNum) {
|
||||||
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter);
|
void* pRetrieve = taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter);
|
||||||
if (!rspObj.rsp.withSchema) {
|
if (!rspObj.rsp.withSchema) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -1653,7 +1665,8 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
||||||
fields[i].bytes = pSW->pSchema[i].bytes;
|
fields[i].bytes = pSW->pSchema[i].bytes;
|
||||||
tstrncpy(fields[i].name, pSW->pSchema[i].name, tListLen(pSW->pSchema[i].name));
|
tstrncpy(fields[i].name, pSW->pSchema[i].name, tListLen(pSW->pSchema[i].name));
|
||||||
}
|
}
|
||||||
code = rawBlockBindData(pQuery, pTableMeta, pRetrieve->data, NULL, fields, pSW->nCols, true);
|
void* rawData = getRawDataFromRes(pRetrieve);
|
||||||
|
code = rawBlockBindData(pQuery, pTableMeta, rawData, NULL, fields, pSW->nCols, true);
|
||||||
taosMemoryFree(fields);
|
taosMemoryFree(fields);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -1737,7 +1750,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
|
|
||||||
uDebug(LOG_ID_TAG" write raw metadata block num:%d", LOG_ID_VALUE, rspObj.rsp.blockNum);
|
uDebug(LOG_ID_TAG" write raw metadata block num:%d", LOG_ID_VALUE, rspObj.rsp.blockNum);
|
||||||
while (++rspObj.resIter < rspObj.rsp.blockNum) {
|
while (++rspObj.resIter < rspObj.rsp.blockNum) {
|
||||||
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter);
|
void* pRetrieve = taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter);
|
||||||
if (!rspObj.rsp.withSchema) {
|
if (!rspObj.rsp.withSchema) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -1824,12 +1837,12 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
||||||
fields[i].bytes = pSW->pSchema[i].bytes;
|
fields[i].bytes = pSW->pSchema[i].bytes;
|
||||||
tstrncpy(fields[i].name, pSW->pSchema[i].name, tListLen(pSW->pSchema[i].name));
|
tstrncpy(fields[i].name, pSW->pSchema[i].name, tListLen(pSW->pSchema[i].name));
|
||||||
}
|
}
|
||||||
code = rawBlockBindData(pQuery, pTableMeta, pRetrieve->data, pCreateReqDst, fields, pSW->nCols, true);
|
void* rawData = getRawDataFromRes(pRetrieve);
|
||||||
|
code = rawBlockBindData(pQuery, pTableMeta, rawData, &pCreateReqDst, fields, pSW->nCols, true);
|
||||||
taosMemoryFree(fields);
|
taosMemoryFree(fields);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
pCreateReqDst = NULL;
|
|
||||||
taosMemoryFreeClear(pTableMeta);
|
taosMemoryFreeClear(pTableMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1577,16 +1577,24 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg,
|
||||||
pRspObj->resInfo.totalRows = 0;
|
pRspObj->resInfo.totalRows = 0;
|
||||||
pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI;
|
pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI;
|
||||||
|
|
||||||
if (!pWrapper->dataRsp.withSchema) {
|
bool needTransformSchema = !pRspObj->rsp.withSchema;
|
||||||
setResSchemaInfo(&pRspObj->resInfo, pWrapper->topicHandle->schema.pSchema, pWrapper->topicHandle->schema.nCols);
|
if (!pRspObj->rsp.withSchema) { // withSchema is false if subscribe subquery, true if subscribe db or stable
|
||||||
|
pRspObj->rsp.withSchema = true;
|
||||||
|
pRspObj->rsp.blockSchema = taosArrayInit(pRspObj->rsp.blockNum, sizeof(void*));
|
||||||
}
|
}
|
||||||
|
// extract the rows in this data packet
|
||||||
// extract the rows in this data packet
|
|
||||||
for (int32_t i = 0; i < pRspObj->rsp.blockNum; ++i) {
|
for (int32_t i = 0; i < pRspObj->rsp.blockNum; ++i) {
|
||||||
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(pRspObj->rsp.blockData, i);
|
SRetrieveTableRspForTmq* pRetrieve = (SRetrieveTableRspForTmq*)taosArrayGetP(pRspObj->rsp.blockData, i);
|
||||||
int64_t rows = htobe64(pRetrieve->numOfRows);
|
int64_t rows = htobe64(pRetrieve->numOfRows);
|
||||||
pVg->numOfRows += rows;
|
pVg->numOfRows += rows;
|
||||||
(*numOfRows) += rows;
|
(*numOfRows) += rows;
|
||||||
|
|
||||||
|
if (needTransformSchema) { //withSchema is false if subscribe subquery, true if subscribe db or stable
|
||||||
|
SSchemaWrapper *schema = tCloneSSchemaWrapper(&pWrapper->topicHandle->schema);
|
||||||
|
if(schema){
|
||||||
|
taosArrayPush(pRspObj->rsp.blockSchema, &schema);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pRspObj;
|
return pRspObj;
|
||||||
|
@ -1603,13 +1611,10 @@ SMqTaosxRspObj* tmqBuildTaosxRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClie
|
||||||
|
|
||||||
pRspObj->resInfo.totalRows = 0;
|
pRspObj->resInfo.totalRows = 0;
|
||||||
pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI;
|
pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI;
|
||||||
if (!pWrapper->taosxRsp.withSchema) {
|
|
||||||
setResSchemaInfo(&pRspObj->resInfo, pWrapper->topicHandle->schema.pSchema, pWrapper->topicHandle->schema.nCols);
|
|
||||||
}
|
|
||||||
|
|
||||||
// extract the rows in this data packet
|
// extract the rows in this data packet
|
||||||
for (int32_t i = 0; i < pRspObj->rsp.blockNum; ++i) {
|
for (int32_t i = 0; i < pRspObj->rsp.blockNum; ++i) {
|
||||||
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(pRspObj->rsp.blockData, i);
|
SRetrieveTableRspForTmq* pRetrieve = (SRetrieveTableRspForTmq*)taosArrayGetP(pRspObj->rsp.blockData, i);
|
||||||
int64_t rows = htobe64(pRetrieve->numOfRows);
|
int64_t rows = htobe64(pRetrieve->numOfRows);
|
||||||
pVg->numOfRows += rows;
|
pVg->numOfRows += rows;
|
||||||
(*numOfRows) += rows;
|
(*numOfRows) += rows;
|
||||||
|
@ -2548,7 +2553,7 @@ SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4) {
|
||||||
pRspObj->resIter++;
|
pRspObj->resIter++;
|
||||||
|
|
||||||
if (pRspObj->resIter < pRspObj->rsp.blockNum) {
|
if (pRspObj->resIter < pRspObj->rsp.blockNum) {
|
||||||
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(pRspObj->rsp.blockData, pRspObj->resIter);
|
SRetrieveTableRspForTmq* pRetrieveTmq = (SRetrieveTableRspForTmq*)taosArrayGetP(pRspObj->rsp.blockData, pRspObj->resIter);
|
||||||
if (pRspObj->rsp.withSchema) {
|
if (pRspObj->rsp.withSchema) {
|
||||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(pRspObj->rsp.blockSchema, pRspObj->resIter);
|
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(pRspObj->rsp.blockSchema, pRspObj->resIter);
|
||||||
setResSchemaInfo(&pRspObj->resInfo, pSW->pSchema, pSW->nCols);
|
setResSchemaInfo(&pRspObj->resInfo, pSW->pSchema, pSW->nCols);
|
||||||
|
@ -2559,7 +2564,16 @@ SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4) {
|
||||||
taosMemoryFreeClear(pRspObj->resInfo.convertJson);
|
taosMemoryFreeClear(pRspObj->resInfo.convertJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
setQueryResultFromRsp(&pRspObj->resInfo, pRetrieve, convertUcs4, false);
|
pRspObj->resInfo.pData = (void*)pRetrieveTmq->data;
|
||||||
|
pRspObj->resInfo.numOfRows = htobe64(pRetrieveTmq->numOfRows);
|
||||||
|
pRspObj->resInfo.current = 0;
|
||||||
|
pRspObj->resInfo.precision = pRetrieveTmq->precision;
|
||||||
|
|
||||||
|
// TODO handle the compressed case
|
||||||
|
pRspObj->resInfo.totalRows += pRspObj->resInfo.numOfRows;
|
||||||
|
setResultDataPtr(&pRspObj->resInfo, pRspObj->resInfo.fields, pRspObj->resInfo.numOfCols, pRspObj->resInfo.numOfRows,
|
||||||
|
convertUcs4);
|
||||||
|
|
||||||
return &pRspObj->resInfo;
|
return &pRspObj->resInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2196,7 +2196,7 @@ int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols) {
|
||||||
|
|
||||||
// todo extract method
|
// todo extract method
|
||||||
int32_t* version = (int32_t*)data;
|
int32_t* version = (int32_t*)data;
|
||||||
*version = 1;
|
*version = 2;
|
||||||
data += sizeof(int32_t);
|
data += sizeof(int32_t);
|
||||||
|
|
||||||
int32_t* actualLen = (int32_t*)data;
|
int32_t* actualLen = (int32_t*)data;
|
||||||
|
@ -2277,7 +2277,7 @@ int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols) {
|
||||||
data += colSizes[col];
|
data += colSizes[col];
|
||||||
}
|
}
|
||||||
|
|
||||||
colSizes[col] = htonl(colSizes[col]);
|
// colSizes[col] = htonl(colSizes[col]);
|
||||||
// uError("blockEncode col bytes:%d, type:%d, size:%d, htonl size:%d", pColRes->info.bytes, pColRes->info.type,
|
// uError("blockEncode col bytes:%d, type:%d, size:%d, htonl size:%d", pColRes->info.bytes, pColRes->info.type,
|
||||||
// htonl(colSizes[col]), colSizes[col]);
|
// htonl(colSizes[col]), colSizes[col]);
|
||||||
}
|
}
|
||||||
|
@ -2293,7 +2293,6 @@ const char* blockDecode(SSDataBlock* pBlock, const char* pData) {
|
||||||
|
|
||||||
int32_t version = *(int32_t*)pStart;
|
int32_t version = *(int32_t*)pStart;
|
||||||
pStart += sizeof(int32_t);
|
pStart += sizeof(int32_t);
|
||||||
ASSERT(version == 1);
|
|
||||||
|
|
||||||
// total length sizeof(int32_t)
|
// total length sizeof(int32_t)
|
||||||
int32_t dataLen = *(int32_t*)pStart;
|
int32_t dataLen = *(int32_t*)pStart;
|
||||||
|
@ -2339,7 +2338,9 @@ const char* blockDecode(SSDataBlock* pBlock, const char* pData) {
|
||||||
pStart += sizeof(int32_t) * numOfCols;
|
pStart += sizeof(int32_t) * numOfCols;
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
colLen[i] = htonl(colLen[i]);
|
if(version == 1){
|
||||||
|
colLen[i] = htonl(colLen[i]);
|
||||||
|
}
|
||||||
ASSERT(colLen[i] >= 0);
|
ASSERT(colLen[i] >= 0);
|
||||||
|
|
||||||
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
|
||||||
|
|
|
@ -16,21 +16,20 @@
|
||||||
#include "tq.h"
|
#include "tq.h"
|
||||||
|
|
||||||
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision) {
|
int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision) {
|
||||||
int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock);
|
int32_t dataStrLen = sizeof(SRetrieveTableRspForTmq) + blockGetEncodeSize(pBlock);
|
||||||
void* buf = taosMemoryCalloc(1, dataStrLen);
|
void* buf = taosMemoryCalloc(1, dataStrLen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)buf;
|
SRetrieveTableRspForTmq* pRetrieve = (SRetrieveTableRspForTmq*)buf;
|
||||||
pRetrieve->useconds = 0;
|
pRetrieve->version = 1;
|
||||||
pRetrieve->precision = precision;
|
pRetrieve->precision = precision;
|
||||||
pRetrieve->compressed = 0;
|
pRetrieve->compressed = 0;
|
||||||
pRetrieve->completed = 1;
|
|
||||||
pRetrieve->numOfRows = htobe64((int64_t)pBlock->info.rows);
|
pRetrieve->numOfRows = htobe64((int64_t)pBlock->info.rows);
|
||||||
|
|
||||||
int32_t actualLen = blockEncode(pBlock, pRetrieve->data, numOfCols);
|
int32_t actualLen = blockEncode(pBlock, pRetrieve->data, numOfCols);
|
||||||
actualLen += sizeof(SRetrieveTableRsp);
|
actualLen += sizeof(SRetrieveTableRspForTmq);
|
||||||
taosArrayPush(pRsp->blockDataLen, &actualLen);
|
taosArrayPush(pRsp->blockDataLen, &actualLen);
|
||||||
taosArrayPush(pRsp->blockData, &buf);
|
taosArrayPush(pRsp->blockData, &buf);
|
||||||
|
|
||||||
|
|
|
@ -1858,7 +1858,7 @@ STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowI
|
||||||
STimeWindow w = {0};
|
STimeWindow w = {0};
|
||||||
if (pResultRowInfo->cur.pageId == -1) { // the first window, from the previous stored value
|
if (pResultRowInfo->cur.pageId == -1) { // the first window, from the previous stored value
|
||||||
getInitialStartTimeWindow(pInterval, ts, &w, (order == TSDB_ORDER_ASC));
|
getInitialStartTimeWindow(pInterval, ts, &w, (order == TSDB_ORDER_ASC));
|
||||||
w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
w.ekey = taosTimeGetIntervalEnd(w.skey, pInterval);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
typedef struct SSessionAggOperatorInfo {
|
typedef struct SSessionAggOperatorInfo {
|
||||||
SOptrBasicInfo binfo;
|
SOptrBasicInfo binfo;
|
||||||
SAggSupporter aggSup;
|
SAggSupporter aggSup;
|
||||||
|
SExprSupp scalarSupp; // supporter for perform scalar function
|
||||||
SGroupResInfo groupResInfo;
|
SGroupResInfo groupResInfo;
|
||||||
SWindowRowsSup winSup;
|
SWindowRowsSup winSup;
|
||||||
bool reptScan; // next round scan
|
bool reptScan; // next round scan
|
||||||
|
@ -1407,6 +1408,10 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pBInfo->pRes->info.scanFlag = pBlock->info.scanFlag;
|
pBInfo->pRes->info.scanFlag = pBlock->info.scanFlag;
|
||||||
|
if (pInfo->scalarSupp.pExprInfo != NULL) {
|
||||||
|
SExprSupp* pExprSup = &pInfo->scalarSupp;
|
||||||
|
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
|
||||||
|
}
|
||||||
// the pDataBlock are always the same one, no need to call this again
|
// the pDataBlock are always the same one, no need to call this again
|
||||||
setInputDataBlock(pSup, pBlock, order, MAIN_SCAN, true);
|
setInputDataBlock(pSup, pBlock, order, MAIN_SCAN, true);
|
||||||
blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId);
|
blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId);
|
||||||
|
@ -1531,6 +1536,8 @@ void destroySWindowOperatorInfo(void* param) {
|
||||||
colDataDestroy(&pInfo->twAggSup.timeWindowData);
|
colDataDestroy(&pInfo->twAggSup.timeWindowData);
|
||||||
|
|
||||||
cleanupAggSup(&pInfo->aggSup);
|
cleanupAggSup(&pInfo->aggSup);
|
||||||
|
cleanupExprSupp(&pInfo->scalarSupp);
|
||||||
|
|
||||||
cleanupGroupResInfo(&pInfo->groupResInfo);
|
cleanupGroupResInfo(&pInfo->groupResInfo);
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
}
|
}
|
||||||
|
@ -1570,6 +1577,16 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionW
|
||||||
pInfo->reptScan = false;
|
pInfo->reptScan = false;
|
||||||
pInfo->binfo.inputTsOrder = pSessionNode->window.node.inputTsOrder;
|
pInfo->binfo.inputTsOrder = pSessionNode->window.node.inputTsOrder;
|
||||||
pInfo->binfo.outputTsOrder = pSessionNode->window.node.outputTsOrder;
|
pInfo->binfo.outputTsOrder = pSessionNode->window.node.outputTsOrder;
|
||||||
|
|
||||||
|
if (pSessionNode->window.pExprs != NULL) {
|
||||||
|
int32_t numOfScalar = 0;
|
||||||
|
SExprInfo* pScalarExprInfo = createExprInfo(pSessionNode->window.pExprs, NULL, &numOfScalar);
|
||||||
|
code = initExprSupp(&pInfo->scalarSupp, pScalarExprInfo, numOfScalar, &pTaskInfo->storageAPI.functionStore);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
code = filterInitFromNode((SNode*)pSessionNode->window.node.pConditions, &pOperator->exprSupp.pFilterInfo, 0);
|
code = filterInitFromNode((SNode*)pSessionNode->window.node.pConditions, &pOperator->exprSupp.pFilterInfo, 0);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
#include "tsimplehash.h"
|
#include "tsimplehash.h"
|
||||||
#include "executor.h"
|
#include "executor.h"
|
||||||
|
#include "executorInt.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
|
@ -186,4 +187,20 @@ TEST(testCase, timewindow_natural) {
|
||||||
ASSERT_EQ(w3.skey, w4.skey);
|
ASSERT_EQ(w3.skey, w4.skey);
|
||||||
ASSERT_EQ(w3.ekey, w4.ekey);
|
ASSERT_EQ(w3.ekey, w4.ekey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST(testCase, timewindow_active) {
|
||||||
|
osSetTimezone("CST");
|
||||||
|
int32_t precision = TSDB_TIME_PRECISION_MILLI;
|
||||||
|
int64_t offset = (int64_t)2*365*24*60*60*1000;
|
||||||
|
SInterval interval = createInterval(10, 10, offset, 'y', 'y', 0, precision);
|
||||||
|
SResultRowInfo dumyInfo = {0};
|
||||||
|
dumyInfo.cur.pageId = -1;
|
||||||
|
int64_t key = (int64_t)1609430400*1000; // 2021-01-01
|
||||||
|
STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, key, &interval, TSDB_ORDER_ASC);
|
||||||
|
printTimeWindow(&win, precision, key);
|
||||||
|
printf("%ld win %ld, %ld\n", key, win.skey, win.ekey);
|
||||||
|
ASSERT_EQ(win.skey, 1325376000000);
|
||||||
|
ASSERT_EQ(win.ekey, 1640908799999);
|
||||||
|
}
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
|
@ -247,13 +247,13 @@ static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreat
|
||||||
if (NULL == pTableCxt->pData) {
|
if (NULL == pTableCxt->pData) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
} else {
|
} else {
|
||||||
pTableCxt->pData->flags = NULL != *pCreateTbReq ? SUBMIT_REQ_AUTO_CREATE_TABLE : 0;
|
pTableCxt->pData->flags = (pCreateTbReq != NULL && NULL != *pCreateTbReq) ? SUBMIT_REQ_AUTO_CREATE_TABLE : 0;
|
||||||
pTableCxt->pData->flags |= colMode ? SUBMIT_REQ_COLUMN_DATA_FORMAT : 0;
|
pTableCxt->pData->flags |= colMode ? SUBMIT_REQ_COLUMN_DATA_FORMAT : 0;
|
||||||
pTableCxt->pData->suid = pTableMeta->suid;
|
pTableCxt->pData->suid = pTableMeta->suid;
|
||||||
pTableCxt->pData->uid = pTableMeta->uid;
|
pTableCxt->pData->uid = pTableMeta->uid;
|
||||||
pTableCxt->pData->sver = pTableMeta->sversion;
|
pTableCxt->pData->sver = pTableMeta->sversion;
|
||||||
pTableCxt->pData->pCreateTbReq = *pCreateTbReq;
|
pTableCxt->pData->pCreateTbReq = pCreateTbReq != NULL ? *pCreateTbReq : NULL;
|
||||||
*pCreateTbReq = NULL;
|
if(pCreateTbReq != NULL) *pCreateTbReq = NULL;
|
||||||
if (pTableCxt->pData->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) {
|
if (pTableCxt->pData->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) {
|
||||||
pTableCxt->pData->aCol = taosArrayInit(128, sizeof(SColData));
|
pTableCxt->pData->aCol = taosArrayInit(128, sizeof(SColData));
|
||||||
if (NULL == pTableCxt->pData->aCol) {
|
if (NULL == pTableCxt->pData->aCol) {
|
||||||
|
@ -640,12 +640,12 @@ static bool findFileds(SSchema* pSchema, TAOS_FIELD* fields, int numFields) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreateTbReq* pCreateTb, TAOS_FIELD* tFields,
|
int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreateTbReq** pCreateTb, TAOS_FIELD* tFields,
|
||||||
int numFields, bool needChangeLength) {
|
int numFields, bool needChangeLength) {
|
||||||
void* tmp = taosHashGet(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid, sizeof(pTableMeta->uid));
|
void* tmp = taosHashGet(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid, sizeof(pTableMeta->uid));
|
||||||
STableDataCxt* pTableCxt = NULL;
|
STableDataCxt* pTableCxt = NULL;
|
||||||
int ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid,
|
int ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid,
|
||||||
sizeof(pTableMeta->uid), pTableMeta, &pCreateTb, &pTableCxt, true, false);
|
sizeof(pTableMeta->uid), pTableMeta, pCreateTb, &pTableCxt, true, false);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
uError("insGetTableDataCxt error");
|
uError("insGetTableDataCxt error");
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -662,6 +662,7 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
|
||||||
char* p = (char*)data;
|
char* p = (char*)data;
|
||||||
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column
|
// | version | total length | total rows | total columns | flag seg| block group id | column schema | each column
|
||||||
// length |
|
// length |
|
||||||
|
int32_t version = *(int32_t*)data;
|
||||||
p += sizeof(int32_t);
|
p += sizeof(int32_t);
|
||||||
p += sizeof(int32_t);
|
p += sizeof(int32_t);
|
||||||
|
|
||||||
|
@ -717,7 +718,7 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
fields += sizeof(int8_t) + sizeof(int32_t);
|
fields += sizeof(int8_t) + sizeof(int32_t);
|
||||||
if (needChangeLength) {
|
if (needChangeLength && version == 1) {
|
||||||
pStart += htonl(colLength[j]);
|
pStart += htonl(colLength[j]);
|
||||||
} else {
|
} else {
|
||||||
pStart += colLength[j];
|
pStart += colLength[j];
|
||||||
|
@ -748,7 +749,7 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
fields += sizeof(int8_t) + sizeof(int32_t);
|
fields += sizeof(int8_t) + sizeof(int32_t);
|
||||||
if (needChangeLength) {
|
if (needChangeLength && version == 1) {
|
||||||
pStart += htonl(colLength[i]);
|
pStart += htonl(colLength[i]);
|
||||||
} else {
|
} else {
|
||||||
pStart += colLength[i];
|
pStart += colLength[i];
|
||||||
|
|
|
@ -3992,6 +3992,42 @@ static int32_t translateSpecificWindow(STranslateContext* pCxt, SSelectStmt* pSe
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static EDealRes collectWindowsPseudocolumns(SNode* pNode, void* pContext) {
|
||||||
|
SNodeList* pCols = (SNodeList*)pContext;
|
||||||
|
if (QUERY_NODE_FUNCTION == nodeType(pNode)) {
|
||||||
|
SFunctionNode* pFunc = (SFunctionNode*)pNode;
|
||||||
|
if (FUNCTION_TYPE_WSTART == pFunc->funcType || FUNCTION_TYPE_WEND == pFunc->funcType ||
|
||||||
|
FUNCTION_TYPE_WDURATION == pFunc->funcType) {
|
||||||
|
nodesListStrictAppend(pCols, nodesCloneNode(pNode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t checkWindowsConditonValid(SNode* pNode) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
if(QUERY_NODE_EVENT_WINDOW != nodeType(pNode)) return code;
|
||||||
|
|
||||||
|
SEventWindowNode* pEventWindowNode = (SEventWindowNode*)pNode;
|
||||||
|
SNodeList* pCols = nodesMakeList();
|
||||||
|
if (NULL == pCols) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
nodesWalkExpr(pEventWindowNode->pStartCond, collectWindowsPseudocolumns, pCols);
|
||||||
|
if (pCols->length > 0) {
|
||||||
|
code = TSDB_CODE_QRY_INVALID_WINDOW_CONDITION;
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
nodesWalkExpr(pEventWindowNode->pEndCond, collectWindowsPseudocolumns, pCols);
|
||||||
|
if (pCols->length > 0) {
|
||||||
|
code = TSDB_CODE_QRY_INVALID_WINDOW_CONDITION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nodesDestroyList(pCols);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t translateWindow(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
static int32_t translateWindow(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
if (NULL == pSelect->pWindow) {
|
if (NULL == pSelect->pWindow) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -4005,6 +4041,9 @@ static int32_t translateWindow(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = translateSpecificWindow(pCxt, pSelect);
|
code = translateSpecificWindow(pCxt, pSelect);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = checkWindowsConditonValid(pSelect->pWindow);
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4526,6 +4565,9 @@ static EDealRes replaceOrderByAliasImpl(SNode** pNode, void* pContext) {
|
||||||
FOREACH(pProject, pProjectionList) {
|
FOREACH(pProject, pProjectionList) {
|
||||||
SExprNode* pExpr = (SExprNode*)pProject;
|
SExprNode* pExpr = (SExprNode*)pProject;
|
||||||
if (0 == strcmp(((SColumnRefNode*)*pNode)->colName, pExpr->userAlias) && nodeType(*pNode) == nodeType(pProject)) {
|
if (0 == strcmp(((SColumnRefNode*)*pNode)->colName, pExpr->userAlias) && nodeType(*pNode) == nodeType(pProject)) {
|
||||||
|
if (QUERY_NODE_COLUMN == nodeType(pProject) && !nodesEqualNode(*pNode, pProject)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
SNode* pNew = nodesCloneNode(pProject);
|
SNode* pNew = nodesCloneNode(pProject);
|
||||||
if (NULL == pNew) {
|
if (NULL == pNew) {
|
||||||
pCxt->pTranslateCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
|
pCxt->pTranslateCxt->errCode = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -1078,9 +1078,8 @@ static int32_t stbSplCreateMergeKeys(SNodeList* pSortKeys, SNodeList* pTargets,
|
||||||
SNode* pTarget = NULL;
|
SNode* pTarget = NULL;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
FOREACH(pTarget, pTargets) {
|
FOREACH(pTarget, pTargets) {
|
||||||
if ((QUERY_NODE_COLUMN == nodeType(pSortExpr) && nodesEqualNode((SNode*)pSortExpr, pTarget))
|
if ((QUERY_NODE_COLUMN == nodeType(pSortExpr) && nodesEqualNode((SNode*)pSortExpr, pTarget)) ||
|
||||||
// || (0 == strcmp(pSortExpr->aliasName, ((SColumnNode*)pTarget)->colName))
|
(0 == strcmp(pSortExpr->aliasName, ((SColumnNode*)pTarget)->colName))) {
|
||||||
) {
|
|
||||||
code = nodesListMakeStrictAppend(&pMergeKeys, stbSplCreateOrderByExpr(pSortKey, pTarget));
|
code = nodesListMakeStrictAppend(&pMergeKeys, stbSplCreateOrderByExpr(pSortKey, pTarget));
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -386,10 +386,13 @@ _return:
|
||||||
int32_t schDumpJobExecRes(SSchJob *pJob, SExecResult *pRes) {
|
int32_t schDumpJobExecRes(SSchJob *pJob, SExecResult *pRes) {
|
||||||
pRes->code = atomic_load_32(&pJob->errCode);
|
pRes->code = atomic_load_32(&pJob->errCode);
|
||||||
pRes->numOfRows = pJob->resNumOfRows;
|
pRes->numOfRows = pJob->resNumOfRows;
|
||||||
|
|
||||||
|
SCH_LOCK(SCH_WRITE, &pJob->resLock);
|
||||||
pRes->res = pJob->execRes.res;
|
pRes->res = pJob->execRes.res;
|
||||||
pRes->msgType = pJob->execRes.msgType;
|
pRes->msgType = pJob->execRes.msgType;
|
||||||
pRes->numOfBytes = pJob->execRes.numOfBytes;
|
pRes->numOfBytes = pJob->execRes.numOfBytes;
|
||||||
pJob->execRes.res = NULL;
|
pJob->execRes.res = NULL;
|
||||||
|
SCH_UNLOCK(SCH_WRITE, &pJob->resLock);
|
||||||
|
|
||||||
SCH_JOB_DLOG("execRes dumped, code: %s", tstrerror(pRes->code));
|
SCH_JOB_DLOG("execRes dumped, code: %s", tstrerror(pRes->code));
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,6 @@
|
||||||
// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
|
// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
|
||||||
// until 00:00:00 January 1, 1970
|
// until 00:00:00 January 1, 1970
|
||||||
static const uint64_t TIMEEPOCH = ((uint64_t)116444736000000000ULL);
|
static const uint64_t TIMEEPOCH = ((uint64_t)116444736000000000ULL);
|
||||||
// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
|
|
||||||
// until 00:00:00 January 1, 1900
|
|
||||||
static const uint64_t TIMEEPOCH1900 = ((uint64_t)116445024000000000ULL);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We do not implement alternate representations. However, we always
|
* We do not implement alternate representations. However, we always
|
||||||
|
@ -360,6 +357,7 @@ int32_t taosGetTimeOfDay(struct timeval *tv) {
|
||||||
t.QuadPart -= TIMEEPOCH;
|
t.QuadPart -= TIMEEPOCH;
|
||||||
tv->tv_sec = t.QuadPart / 10000000;
|
tv->tv_sec = t.QuadPart / 10000000;
|
||||||
tv->tv_usec = (t.QuadPart % 10000000) / 10;
|
tv->tv_usec = (t.QuadPart % 10000000) / 10;
|
||||||
|
return 0;
|
||||||
#else
|
#else
|
||||||
return gettimeofday(tv, NULL);
|
return gettimeofday(tv, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
@ -482,33 +480,51 @@ struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf) {
|
||||||
sprintf(buf, "NaN");
|
sprintf(buf, "NaN");
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
} else if (*timep < 0) {
|
||||||
|
SYSTEMTIME ss, s;
|
||||||
|
FILETIME ff, f;
|
||||||
|
|
||||||
SYSTEMTIME s;
|
LARGE_INTEGER offset;
|
||||||
FILETIME f;
|
struct tm tm1;
|
||||||
LARGE_INTEGER offset;
|
time_t tt = 0;
|
||||||
struct tm tm1;
|
if (localtime_s(&tm1, &tt) != 0) {
|
||||||
time_t tt = 0;
|
if (buf != NULL) {
|
||||||
if (localtime_s(&tm1, &tt) != 0) {
|
sprintf(buf, "NaN");
|
||||||
if (buf != NULL) {
|
}
|
||||||
sprintf(buf, "NaN");
|
return NULL;
|
||||||
|
}
|
||||||
|
ss.wYear = tm1.tm_year + 1900;
|
||||||
|
ss.wMonth = tm1.tm_mon + 1;
|
||||||
|
ss.wDay = tm1.tm_mday;
|
||||||
|
ss.wHour = tm1.tm_hour;
|
||||||
|
ss.wMinute = tm1.tm_min;
|
||||||
|
ss.wSecond = tm1.tm_sec;
|
||||||
|
ss.wMilliseconds = 0;
|
||||||
|
SystemTimeToFileTime(&ss, &ff);
|
||||||
|
offset.QuadPart = ff.dwHighDateTime;
|
||||||
|
offset.QuadPart <<= 32;
|
||||||
|
offset.QuadPart |= ff.dwLowDateTime;
|
||||||
|
offset.QuadPart += *timep * 10000000;
|
||||||
|
f.dwLowDateTime = offset.QuadPart & 0xffffffff;
|
||||||
|
f.dwHighDateTime = (offset.QuadPart >> 32) & 0xffffffff;
|
||||||
|
FileTimeToSystemTime(&f, &s);
|
||||||
|
result->tm_sec = s.wSecond;
|
||||||
|
result->tm_min = s.wMinute;
|
||||||
|
result->tm_hour = s.wHour;
|
||||||
|
result->tm_mday = s.wDay;
|
||||||
|
result->tm_mon = s.wMonth - 1;
|
||||||
|
result->tm_year = s.wYear - 1900;
|
||||||
|
result->tm_wday = s.wDayOfWeek;
|
||||||
|
result->tm_yday = 0;
|
||||||
|
result->tm_isdst = 0;
|
||||||
|
} else {
|
||||||
|
if (localtime_s(result, timep) != 0) {
|
||||||
|
if (buf != NULL) {
|
||||||
|
sprintf(buf, "NaN");
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
offset.QuadPart = TIMEEPOCH1900;
|
|
||||||
offset.QuadPart += *timep * 10000000;
|
|
||||||
f.dwLowDateTime = offset.QuadPart & 0xffffffff;
|
|
||||||
f.dwHighDateTime = (offset.QuadPart >> 32) & 0xffffffff;
|
|
||||||
FileTimeToSystemTime(&f, &s);
|
|
||||||
result->tm_sec = s.wSecond;
|
|
||||||
result->tm_min = s.wMinute;
|
|
||||||
result->tm_hour = s.wHour;
|
|
||||||
result->tm_mday = s.wDay;
|
|
||||||
result->tm_mon = s.wMonth - 1;
|
|
||||||
result->tm_year = s.wYear - 1900;
|
|
||||||
result->tm_wday = s.wDayOfWeek;
|
|
||||||
result->tm_yday = 0;
|
|
||||||
result->tm_isdst = 0;
|
|
||||||
#else
|
#else
|
||||||
res = localtime_r(timep, result);
|
res = localtime_r(timep, result);
|
||||||
if (res == NULL && buf != NULL) {
|
if (res == NULL && buf != NULL) {
|
||||||
|
|
|
@ -426,6 +426,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_JSON_IN_GROUP_ERROR, "Json not support in g
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_JOB_NOT_EXIST, "Job not exist")
|
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_JOB_NOT_EXIST, "Job not exist")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_QWORKER_QUIT, "Vnode/Qnode is quitting")
|
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_QWORKER_QUIT, "Vnode/Qnode is quitting")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_GEO_NOT_SUPPORT_ERROR, "Geometry not support in this operator")
|
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_GEO_NOT_SUPPORT_ERROR, "Geometry not support in this operator")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_WINDOW_CONDITION, "The time pseudo column is illegally used in the condition of the event window.")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR, "Executor internal error")
|
TAOS_DEFINE_ERROR(TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR, "Executor internal error")
|
||||||
|
|
||||||
// grant
|
// grant
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
import taos
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import glob
|
||||||
|
import shutil
|
||||||
|
import time
|
||||||
|
|
||||||
|
from frame.log import *
|
||||||
|
from frame.cases import *
|
||||||
|
from frame.sql import *
|
||||||
|
from frame.caseBase import *
|
||||||
|
from frame import *
|
||||||
|
from frame.autogen import *
|
||||||
|
from frame.server.dnodes import *
|
||||||
|
from frame.server.cluster import *
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase(TBase):
|
||||||
|
|
||||||
|
def init(self, conn, logSql, replicaVar=3):
|
||||||
|
super(TDTestCase, self).init(conn, logSql, replicaVar=3, db="snapshot", checkColName="c1")
|
||||||
|
self.valgrind = 0
|
||||||
|
self.childtable_count = 10
|
||||||
|
# tdSql.init(conn.cursor())
|
||||||
|
tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
tdSql.prepare()
|
||||||
|
autoGen = AutoGen()
|
||||||
|
autoGen.create_db(self.db, 2, 3)
|
||||||
|
tdSql.execute(f"use {self.db}")
|
||||||
|
autoGen.create_stable(self.stb, 5, 10, 8, 8)
|
||||||
|
autoGen.create_child(self.stb, "d", self.childtable_count)
|
||||||
|
autoGen.insert_data(1000)
|
||||||
|
tdSql.execute(f"flush database {self.db}")
|
||||||
|
clusterDnodes.stoptaosd(3)
|
||||||
|
# clusterDnodes.stoptaosd(1)
|
||||||
|
# clusterDnodes.starttaosd(3)
|
||||||
|
# time.sleep(5)
|
||||||
|
# clusterDnodes.stoptaosd(2)
|
||||||
|
# clusterDnodes.starttaosd(1)
|
||||||
|
# time.sleep(5)
|
||||||
|
autoGen.insert_data(5000, True)
|
||||||
|
tdSql.execute(f"flush database {self.db}")
|
||||||
|
|
||||||
|
# sql = 'show vnodes;'
|
||||||
|
# while True:
|
||||||
|
# bFinish = True
|
||||||
|
# param_list = tdSql.query(sql, row_tag=True)
|
||||||
|
# for param in param_list:
|
||||||
|
# if param[3] == 'leading' or param[3] == 'following':
|
||||||
|
# bFinish = False
|
||||||
|
# break
|
||||||
|
# if bFinish:
|
||||||
|
# break
|
||||||
|
self.snapshotAgg()
|
||||||
|
time.sleep(10)
|
||||||
|
clusterDnodes.stopAll()
|
||||||
|
for i in range(1, 4):
|
||||||
|
path = clusterDnodes.getDnodeDir(i)
|
||||||
|
dnodesRootDir = os.path.join(path,"data","vnode", "vnode*")
|
||||||
|
dirs = glob.glob(dnodesRootDir)
|
||||||
|
for dir in dirs:
|
||||||
|
if os.path.isdir(dir):
|
||||||
|
tdLog.debug("delete dir: %s " % (dnodesRootDir))
|
||||||
|
self.remove_directory(os.path.join(dir, "wal"))
|
||||||
|
|
||||||
|
clusterDnodes.starttaosd(1)
|
||||||
|
clusterDnodes.starttaosd(2)
|
||||||
|
clusterDnodes.starttaosd(3)
|
||||||
|
sql = "show vnodes;"
|
||||||
|
time.sleep(10)
|
||||||
|
while True:
|
||||||
|
bFinish = True
|
||||||
|
param_list = tdSql.query(sql, row_tag=True)
|
||||||
|
for param in param_list:
|
||||||
|
if param[3] == 'offline':
|
||||||
|
tdLog.exit(
|
||||||
|
"dnode synchronous fail dnode id: %d, vgroup id:%d status offline" % (param[0], param[1]))
|
||||||
|
if param[3] == 'leading' or param[3] == 'following':
|
||||||
|
bFinish = False
|
||||||
|
break
|
||||||
|
if bFinish:
|
||||||
|
break
|
||||||
|
|
||||||
|
self.timestamp_step = 1
|
||||||
|
self.insert_rows = 6000
|
||||||
|
self.checkInsertCorrect()
|
||||||
|
self.checkAggCorrect()
|
||||||
|
|
||||||
|
def remove_directory(self, directory):
|
||||||
|
try:
|
||||||
|
shutil.rmtree(directory)
|
||||||
|
tdLog.debug("delete dir: %s " % (directory))
|
||||||
|
except OSError as e:
|
||||||
|
tdLog.exit("delete fail dir: %s " % (directory))
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -0,0 +1,61 @@
|
||||||
|
{
|
||||||
|
"filetype": "insert",
|
||||||
|
"cfgdir": "/etc/taos",
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"port": 6030,
|
||||||
|
"user": "root",
|
||||||
|
"password": "taosdata",
|
||||||
|
"connection_pool_size": 8,
|
||||||
|
"num_of_records_per_req": 4000,
|
||||||
|
"prepared_rand": 10000,
|
||||||
|
"thread_count": 3,
|
||||||
|
"create_table_thread_count": 1,
|
||||||
|
"confirm_parameter_prompt": "no",
|
||||||
|
"databases": [
|
||||||
|
{
|
||||||
|
"dbinfo": {
|
||||||
|
"name": "db",
|
||||||
|
"drop": "no",
|
||||||
|
"vgroups": 3,
|
||||||
|
"replica": 3,
|
||||||
|
"duration":"3d",
|
||||||
|
"wal_retention_period": 1,
|
||||||
|
"wal_retention_size": 1,
|
||||||
|
"stt_trigger": 1
|
||||||
|
},
|
||||||
|
"super_tables": [
|
||||||
|
{
|
||||||
|
"name": "stb",
|
||||||
|
"child_table_exists": "yes",
|
||||||
|
"childtable_count": 6,
|
||||||
|
"insert_rows": 50000,
|
||||||
|
"childtable_prefix": "d",
|
||||||
|
"insert_mode": "taosc",
|
||||||
|
"timestamp_step": 60000,
|
||||||
|
"start_timestamp":1700000000000,
|
||||||
|
"columns": [
|
||||||
|
{ "type": "bool", "name": "bc"},
|
||||||
|
{ "type": "float", "name": "fc" },
|
||||||
|
{ "type": "double", "name": "dc"},
|
||||||
|
{ "type": "tinyint", "name": "ti"},
|
||||||
|
{ "type": "smallint", "name": "si" },
|
||||||
|
{ "type": "int", "name": "ic" },
|
||||||
|
{ "type": "bigint", "name": "bi" },
|
||||||
|
{ "type": "utinyint", "name": "uti"},
|
||||||
|
{ "type": "usmallint", "name": "usi"},
|
||||||
|
{ "type": "uint", "name": "ui" },
|
||||||
|
{ "type": "ubigint", "name": "ubi"},
|
||||||
|
{ "type": "binary", "name": "bin", "len": 8},
|
||||||
|
{ "type": "nchar", "name": "nch", "len": 16}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
{"type": "tinyint", "name": "groupid","max": 10,"min": 1},
|
||||||
|
{"name": "location","type": "binary", "len": 16, "values":
|
||||||
|
["San Francisco", "Los Angles", "San Diego", "San Jose", "Palo Alto", "Campbell", "Mountain View","Sunnyvale", "Santa Clara", "Cupertino"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
import taos
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from frame.log import *
|
||||||
|
from frame.cases import *
|
||||||
|
from frame.sql import *
|
||||||
|
from frame.caseBase import *
|
||||||
|
from frame import *
|
||||||
|
|
||||||
|
class TDTestCase(TBase):
|
||||||
|
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
#tdSql.init(conn.cursor())
|
||||||
|
tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
dbname = "db"
|
||||||
|
stbname = "ocloud_point"
|
||||||
|
tbname = "ocloud_point_170658_3837620225_1701134595725266945"
|
||||||
|
|
||||||
|
tdSql.prepare()
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("==========step1:create table")
|
||||||
|
|
||||||
|
tdSql.execute(
|
||||||
|
f'''create stable if not exists {dbname}.{stbname}
|
||||||
|
(wstart timestamp, point_value float) tags (location binary(64), groupId int)
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
|
||||||
|
tdSql.execute(
|
||||||
|
f'''create table if not exists {dbname}.{tbname} using {dbname}.{stbname} tags("California.SanFrancisco", 2)'''
|
||||||
|
)
|
||||||
|
|
||||||
|
sqls = []
|
||||||
|
for i in range(35, 41):
|
||||||
|
if i == 38 or i == 40:
|
||||||
|
sqls.append(f"insert into {dbname}.{tbname} values('2023-12-26 10:{i}:00.000', null)")
|
||||||
|
else:
|
||||||
|
sqls.append(f"insert into {dbname}.{tbname} values('2023-12-26 10:{i}:00.000', 5.0)")
|
||||||
|
|
||||||
|
# sqls.append(f"insert into {dbname}.{tbname} values('2023-12-26 10:36:00.000', 5.0)")
|
||||||
|
# sqls.append(f"insert into {dbname}.{tbname} values('2023-12-26 10:37:00.000', 5.0)")
|
||||||
|
# sqls.append(f"insert into {dbname}.{tbname} values('2023-12-26 10:38:00.000', null)")
|
||||||
|
# sqls.append(f"insert into {dbname}.{tbname} values('2023-12-26 10:39:00.000', 5.0)")
|
||||||
|
# sqls.append(f"insert into {dbname}.{tbname} values('2023-12-26 10:40:00.000', null)")
|
||||||
|
|
||||||
|
|
||||||
|
tdSql.executes(sqls)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("==========step3:fill data")
|
||||||
|
|
||||||
|
tdSql.query(f"select first(point_value) as pointValue from {dbname}.{tbname} where wstart between '2023-12-26 10:35:00' and '2023-12-26 10:40:00' interval(1M) fill(prev) order by wstart desc limit 100")
|
||||||
|
data = []
|
||||||
|
for i in range(6):
|
||||||
|
row = [5]
|
||||||
|
data.append(row)
|
||||||
|
tdSql.checkDataMem(data)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -0,0 +1,447 @@
|
||||||
|
from frame.log import *
|
||||||
|
from frame.cases import *
|
||||||
|
from frame.sql import *
|
||||||
|
from frame.caseBase import *
|
||||||
|
from frame import *
|
||||||
|
from frame.eos import *
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase(TBase):
|
||||||
|
"""Verify the elapsed function
|
||||||
|
"""
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
self.dbname = 'db'
|
||||||
|
self.table_dic = {
|
||||||
|
"super_table": ["st1", "st2", "st_empty"],
|
||||||
|
"child_table": ["ct1_1", "ct1_2", "ct1_empty", "ct2_1", "ct2_2", "ct2_empty"],
|
||||||
|
"tags_value": [("2023-03-01 15:00:00", 1, 'bj'), ("2023-03-01 15:10:00", 2, 'sh'), ("2023-03-01 15:20:00", 3, 'sz'), ("2023-03-01 15:00:00", 4, 'gz'), ("2023-03-01 15:10:00", 5, 'cd'), ("2023-03-01 15:20:00", 6, 'hz')],
|
||||||
|
"common_table": ["t1", "t2", "t_empty"]
|
||||||
|
}
|
||||||
|
self.start_ts = 1677654000000 # 2023-03-01 15:00:00.000
|
||||||
|
self.row_num = 100
|
||||||
|
|
||||||
|
def prepareData(self):
|
||||||
|
# db
|
||||||
|
tdSql.execute(f"create database {self.dbname};")
|
||||||
|
tdSql.execute(f"use {self.dbname};")
|
||||||
|
tdLog.debug(f"Create database {self.dbname}")
|
||||||
|
|
||||||
|
# commont table
|
||||||
|
for common_table in self.table_dic["common_table"]:
|
||||||
|
tdSql.execute(f"create table {common_table} (ts timestamp, c_ts timestamp, c_int int, c_bigint bigint, c_double double, c_nchar nchar(16));")
|
||||||
|
tdLog.debug("Create common table %s" % common_table)
|
||||||
|
|
||||||
|
# super table
|
||||||
|
for super_table in self.table_dic["super_table"]:
|
||||||
|
tdSql.execute(f"create stable {super_table} (ts timestamp, c_ts timestamp, c_int int, c_bigint bigint, c_double double, c_nchar nchar(16)) tags (t1 timestamp, t2 int, t3 binary(16));")
|
||||||
|
tdLog.debug("Create super table %s" % super_table)
|
||||||
|
|
||||||
|
# child table
|
||||||
|
for i in range(len(self.table_dic["child_table"])):
|
||||||
|
if self.table_dic["child_table"][i].startswith("ct1"):
|
||||||
|
tdSql.execute("create table {} using {} tags('{}', {}, '{}');".format(self.table_dic["child_table"][i], "st1", self.table_dic["tags_value"][i][0], self.table_dic["tags_value"][i][1], self.table_dic["tags_value"][i][2]))
|
||||||
|
elif self.table_dic["child_table"][i].startswith("ct2"):
|
||||||
|
tdSql.execute("create table {} using {} tags('{}', {}, '{}');".format(self.table_dic["child_table"][i], "st2", self.table_dic["tags_value"][i][0], self.table_dic["tags_value"][i][1], self.table_dic["tags_value"][i][2]))
|
||||||
|
|
||||||
|
# insert data
|
||||||
|
table_list = ["t1", "t2", "ct1_1", "ct1_2", "ct2_1", "ct2_2"]
|
||||||
|
for t in table_list:
|
||||||
|
sql = "insert into {} values".format(t)
|
||||||
|
for i in range(self.row_num):
|
||||||
|
sql += "({}, {}, {}, {}, {}, '{}'),".format(self.start_ts + i * 1000, self.start_ts + i * 1000, 32767+i, 65535+i, i, t + str(i))
|
||||||
|
sql += ";"
|
||||||
|
tdSql.execute(sql)
|
||||||
|
tdLog.debug("Insert data into table %s" % t)
|
||||||
|
|
||||||
|
def test_normal_query(self):
|
||||||
|
# only one timestamp
|
||||||
|
tdSql.query("select elapsed(ts) from t1 group by c_ts;")
|
||||||
|
tdSql.checkRows(self.row_num)
|
||||||
|
tdSql.checkData(0, 0, 0)
|
||||||
|
|
||||||
|
tdSql.query("select elapsed(ts, 1m) from t1 group by c_ts;")
|
||||||
|
tdSql.checkRows(self.row_num)
|
||||||
|
tdSql.checkData(0, 0, 0)
|
||||||
|
|
||||||
|
# child table with group by
|
||||||
|
tdSql.query("select elapsed(ts) from ct1_2 group by tbname;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
tdSql.checkData(0, 0, 99000)
|
||||||
|
|
||||||
|
# empty super table
|
||||||
|
tdSql.query("select elapsed(ts, 1s) from st_empty group by tbname;")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
# empty child table
|
||||||
|
tdSql.query("select elapsed(ts, 1s) from ct1_empty group by tbname;")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
# empty common table
|
||||||
|
tdSql.query("select elapsed(ts, 1s) from t_empty group by tbname;")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
# unit as second
|
||||||
|
tdSql.query("select elapsed(ts, 1s) from st2 group by tbname;")
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
tdSql.checkData(0, 0, 99)
|
||||||
|
|
||||||
|
# unit as minute
|
||||||
|
tdSql.query("select elapsed(ts, 1m) from st2 group by tbname;")
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
tdSql.checkData(0, 0, 1.65)
|
||||||
|
|
||||||
|
# unit as hour
|
||||||
|
tdSql.query("select elapsed(ts, 1h) from st2 group by tbname;")
|
||||||
|
tdSql.checkRows(2)
|
||||||
|
tdSql.checkData(0, 0, 0.0275)
|
||||||
|
|
||||||
|
def test_query_with_filter(self):
|
||||||
|
end_ts = 1677654000000 + 1000 * 99
|
||||||
|
query_list = [
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st1 where ts >= 1677654000000 group by tbname;",
|
||||||
|
"res": [(99.0, ), (99.0, )]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st1 where ts >= 1677654000000 and c_ts >= 1677654000000 group by tbname;",
|
||||||
|
"res": [(99.0, ), (99.0, )]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st1 where ts >= 1677654000000 and c_ts >= 1677654000000 and t1='2023-03-01 15:10:00.000' group by tbname;",
|
||||||
|
"res": [(99.0, )]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st_empty where ts >= 1677654000000 and c_ts >= 1677654000000 and t1='2023-03-01 15:10:00.000' group by tbname;",
|
||||||
|
"res": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from ct1_1 where ts >= 1677654000000 group by tbname;",
|
||||||
|
"res": [(99.0, )]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from ct1_2 where ts >= 1677654000000 and c_ts >= 1677654000000 group by tbname;",
|
||||||
|
"res": [(99.0, )]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from ct1_empty where ts >= 1677654000000 and c_ts >= 1677654000000 group by tbname;",
|
||||||
|
"res": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from t1 where ts >= 1677654000000 group by tbname;",
|
||||||
|
"res": [(99.0, )]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from t2 where ts >= 1677654000000 and c_ts >= 1677654000000 group by tbname;",
|
||||||
|
"res": [(99.0, )]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from t_empty where ts >= 1677654000000 and c_ts >= 1677654000000 group by tbname;",
|
||||||
|
"res": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st2 where ts >= 1677654000000 and c_ts > {} group by tbname;".format(end_ts),
|
||||||
|
"res": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st2 where ts >= 1677654000000 and c_ts > {} and t1='2023-03-01 15:10:00' group by tbname;".format(end_ts),
|
||||||
|
"res": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st2 where ts >= 1677654000000 and c_int < 1 group by tbname;",
|
||||||
|
"res": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st2 where ts >= 1677654000000 and c_int >= 1 and t1='2023-03-01 15:10:00' group by tbname;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st2 where ts >= 1677654000000 and c_int <> 1 and t1='2023-03-01 15:10:00' group by tbname;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st2 where ts >= 1677654000000 and c_nchar like 'ct2_%' and t1='2023-03-01 15:10:00' group by tbname;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st2 where ts >= 1677654000000 and c_nchar like 'ct1_%' and t1='2023-03-01 15:10:00' group by tbname;",
|
||||||
|
"res": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st2 where ts >= 1677654000000 and c_nchar match '^ct2_' and t1='2023-03-01 15:10:00' group by tbname;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st2 where ts >= 1677654000000 and c_nchar nmatch '^ct1_' and t1='2023-03-01 15:10:00' group by tbname;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st2 where ts >= 1677654000000 and t3 like 'g%' group by tbname;",
|
||||||
|
"res": [(99,)]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
sql_list = []
|
||||||
|
res_list = []
|
||||||
|
for item in query_list:
|
||||||
|
sql_list.append(item["sql"])
|
||||||
|
res_list.append(item["res"])
|
||||||
|
tdSql.queryAndCheckResult(sql_list, res_list)
|
||||||
|
|
||||||
|
def test_query_with_other_function(self):
|
||||||
|
query_list = [
|
||||||
|
{
|
||||||
|
"sql": "select avg(c_int), count(*), elapsed(ts, 1s), leastsquares(c_int, 0, 1), spread(c_bigint), sum(c_int), hyperloglog(c_int) from st1;",
|
||||||
|
"res": [(32816.5, 200, 99.0, '{slop:0.499962, intercept:32766.753731}', 99.0, 6563300, 100)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select twa(c_int) * elapsed(ts, 1s) from ct1_1;",
|
||||||
|
"res": [(3.248833500000000e+06,)]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
sql_list = []
|
||||||
|
res_list = []
|
||||||
|
for item in query_list:
|
||||||
|
sql_list.append(item["sql"])
|
||||||
|
res_list.append(item["res"])
|
||||||
|
tdSql.queryAndCheckResult(sql_list, res_list)
|
||||||
|
|
||||||
|
def test_query_with_join(self):
|
||||||
|
query_list = [
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(st1.ts, 1s) from st1, st2 where st1.ts = st2.ts;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(st1.ts, 1s) from st1, st_empty where st1.ts = st_empty.ts and st1.c_ts = st_empty.c_ts;",
|
||||||
|
"res": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(st1.ts, 1s) from st1, ct1_1 where st1.ts = ct1_1.ts;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ct1.ts, 1s) from ct1_1 ct1, ct1_2 ct2 where ct1.ts = ct2.ts;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ct1.ts, 1s) from ct1_1 ct1, ct1_empty ct2 where ct1.ts = ct2.ts;",
|
||||||
|
"res": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(st1.ts, 1s) from st1, ct1_empty where st1.ts = ct1_empty.ts;",
|
||||||
|
"res": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(st1.ts, 1s) from st1, t1 where st1.ts = t1.ts;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(st1.ts, 1s) from st1, t_empty where st1.ts = t_empty.ts;",
|
||||||
|
"res": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ct1.ts, 1s) from ct1_1 ct1, t1 t2 where ct1.ts = t2.ts;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ct1.ts, 1s) from ct1_1 ct1, t_empty t2 where ct1.ts = t2.ts;",
|
||||||
|
"res": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(st1.ts, 1s) from st1, st2, st_empty where st1.ts=st2.ts and st2.ts=st_empty.ts;",
|
||||||
|
"res": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
sql_list = []
|
||||||
|
res_list = []
|
||||||
|
for item in query_list:
|
||||||
|
sql_list.append(item["sql"])
|
||||||
|
res_list.append(item["res"])
|
||||||
|
tdSql.queryAndCheckResult(sql_list, res_list)
|
||||||
|
|
||||||
|
def test_query_with_union(self):
|
||||||
|
query_list = [
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st1 union select elapsed(ts, 1s) from st2;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st1 union all select elapsed(ts, 1s) from st2;",
|
||||||
|
"res": [(99,),(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st1 union all select elapsed(ts, 1s) from st_empty;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from ct1_1 union all select elapsed(ts, 1s) from ct1_2;",
|
||||||
|
"res": [(99,),(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from ct1_1 union select elapsed(ts, 1s) from ct1_2;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from ct1_1 union select elapsed(ts, 1s) from ct1_empty;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st1 where ts < '2023-03-01 15:05:00.000' union select elapsed(ts, 1s) from ct1_1 where ts >= '2023-03-01 15:01:00.000';",
|
||||||
|
"res": [(39,),(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from ct1_empty union select elapsed(ts, 1s) from t_empty;",
|
||||||
|
"res": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st1 group by tbname union select elapsed(ts, 1s) from st2 group by tbname;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st1 group by tbname union all select elapsed(ts, 1s) from st2 group by tbname;",
|
||||||
|
"res": [(99,),(99,),(99,),(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st_empty group by tbname union all select elapsed(ts, 1s) from st2 group by tbname;",
|
||||||
|
"res": [(99,),(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from t1 where ts between '2023-03-01 15:00:00.000' and '2023-03-01 15:01:40.000' interval(10s) fill(next) union select elapsed(ts, 1s) from st2 where ts between '2023-03-01 15:00:00.000' and '2023-03-01 15:01:49.000' interval(5s) fill(prev);",
|
||||||
|
"res": [(9,), (None,), (4,), (5,),(10,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st1 group by tbname union select elapsed(ts, 1s) from st2 group by tbname union select elapsed(ts, 1s) from st_empty group by tbname;",
|
||||||
|
"res": [(99,)]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
sql_list = []
|
||||||
|
res_list = []
|
||||||
|
for item in query_list:
|
||||||
|
sql_list.append(item["sql"])
|
||||||
|
res_list.append(item["res"])
|
||||||
|
tdSql.queryAndCheckResult(sql_list, res_list)
|
||||||
|
|
||||||
|
def test_query_with_window(self):
|
||||||
|
query_list = [
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st1 where ts between '2023-03-01 15:00:00.000' and '2023-03-01 15:00:20.000' interval(10s) fill(next);",
|
||||||
|
"res": [(10,),(10,)()]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from (select * from st1 where ts between '2023-03-01 15:00:00.000' and '2023-03-01 15:01:20.000' and c_int > 100) where ts >= '2023-03-01 15:01:00.000' and ts < '2023-03-01 15:02:00.000' interval(10s) fill(prev);",
|
||||||
|
"res": [(10,)(10,)(),(),(),()]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st1 where ts between '2023-03-01 15:00:00.000' and '2023-03-01 15:00:20.000' session(ts, 2s);",
|
||||||
|
"res": [(20,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from st_empty where ts between '2023-03-01 15:00:00.000' and '2023-03-01 15:00:20.000' session(ts, 2s);",
|
||||||
|
"res": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
sql_list = []
|
||||||
|
res_list = []
|
||||||
|
for item in query_list:
|
||||||
|
sql_list.append(item["sql"])
|
||||||
|
res_list.append(item["res"])
|
||||||
|
tdSql.queryAndCheckResult(sql_list, res_list)
|
||||||
|
|
||||||
|
def test_nested_query(self):
|
||||||
|
query_list = [
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from (select * from st1 where c_int > 10 and ts between '2023-03-01 15:00:00.000' and '2023-03-01 15:01:40.000');",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select sum(v) from (select elapsed(ts, 1s) as v from st1 where ts between '2023-03-01 15:00:00.000' and '2023-03-01 15:00:20.000' interval(10s) fill(next));",
|
||||||
|
"res": [(20,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select avg(v) from (select elapsed(ts, 1s) as v from st2 group by tbname order by v);",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from (select * from st1 where ts between '2023-03-01 15:00:00.000' and '2023-03-01 15:01:40.000') where c_int > 10;",
|
||||||
|
"res": [(99,)]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sql": "select elapsed(ts, 1s) from (select * from st1 where c_int > 10 and ts between '2023-03-01 15:00:00.000' and '2023-03-01 15:01:40.000') where c_int < 20;",
|
||||||
|
"res": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
sql_list = []
|
||||||
|
res_list = []
|
||||||
|
for item in query_list:
|
||||||
|
sql_list.append(item["sql"])
|
||||||
|
res_list.append(item["res"])
|
||||||
|
tdSql.queryAndCheckResult(sql_list, res_list)
|
||||||
|
|
||||||
|
def test_abnormal_query(self):
|
||||||
|
# incorrect parameter
|
||||||
|
table_list = self.table_dic["super_table"] + self.table_dic["child_table"] + self.table_dic["common_table"]
|
||||||
|
incorrect_parameter_list = ["()", "(null)", "(*)", "(c_ts)", "(c_ts, 1s)", "(c_int)", "(c_bigint)", "(c_double)", "(c_nchar)", "(ts, null)",
|
||||||
|
"(ts, *)", "(2024-01-09 17:00:00)", "(2024-01-09 17:00:00, 1s)", "(t1)", "(t1, 1s)", "(t2)", "(t3)"]
|
||||||
|
for table in table_list:
|
||||||
|
for param in incorrect_parameter_list:
|
||||||
|
if table.startswith("st"):
|
||||||
|
tdSql.error("select elapsed{} from {} group by tbname order by ts;".format(param, table))
|
||||||
|
else:
|
||||||
|
tdSql.error("select elapsed{} from {};".format(param, table))
|
||||||
|
tdSql.error("select elapsed{} from {} group by ".format(param, table))
|
||||||
|
|
||||||
|
# query with unsupported function, like leastsquares、diff、derivative、top、bottom、last_row、interp
|
||||||
|
unsupported_sql_list = [
|
||||||
|
"select elapsed(leastsquares(c_int, 1, 2)) from st1 group by tbname;",
|
||||||
|
"select elapsed(diff(ts)) from st1;",
|
||||||
|
"select elapsed(derivative(ts, 1s, 1)) from st1 group by tbname order by ts;",
|
||||||
|
"select elapsed(top(ts, 5)) from st1 group by tbname order by ts;",
|
||||||
|
"select top(elapsed(ts), 5) from st1 group by tbname order by ts;",
|
||||||
|
"select elapsed(bottom(ts)) from st1 group by tbname order by ts;",
|
||||||
|
"select bottom(elapsed(ts)) from st1 group by tbname order by ts;",
|
||||||
|
"select elapsed(last_row(ts)) from st1 group by tbname order by ts;",
|
||||||
|
"select elapsed(interp(ts, 0)) from st1 group by tbname order by ts;"
|
||||||
|
]
|
||||||
|
tdSql.errors(unsupported_sql_list)
|
||||||
|
|
||||||
|
# nested aggregate function
|
||||||
|
nested_sql_list = [
|
||||||
|
"select avg(elapsed(ts, 1s)) from st1 group by tbname order by ts;",
|
||||||
|
"select elapsed(avg(ts), 1s) from st1 group by tbname order by ts;",
|
||||||
|
"select elapsed(sum(ts), 1s) from st1 group by tbname order by ts;",
|
||||||
|
"select elapsed(count(ts), 1s) from st1 group by tbname order by ts;",
|
||||||
|
"select elapsed(min(ts), 1s) from st1 group by tbname order by ts;",
|
||||||
|
"select elapsed(max(ts), 1s) from st1 group by tbname order by ts;",
|
||||||
|
"select elapsed(first(ts), 1s) from st1 group by tbname order by ts;",
|
||||||
|
"select elapsed(last(ts), 1s) from st1 group by tbname order by ts;"
|
||||||
|
]
|
||||||
|
tdSql.errors(nested_sql_list)
|
||||||
|
|
||||||
|
# other error
|
||||||
|
other_sql_list = [
|
||||||
|
"select elapsed(ts, 1s) from t1 where ts between '2023-03-01 15:00:00.000' and '2023-03-01 15:01:40.000' interval(10s) fill(next) union select elapsed(ts, 1s) from st2 where ts between '2023-03-01 15:00:00.000' and '2023-03-01 15:01:49.000' interval(5s) fill(prev) group by tbname;",
|
||||||
|
"select elapsed(time ,1s) from (select elapsed(ts,1s) time from st1);",
|
||||||
|
"select elapsed(ts , 1s) from (select elapsed(ts, 1s) ts from st2);",
|
||||||
|
"select elapsed(time, 1s) from (select elapsed(ts, 1s) time from st1 group by tbname);",
|
||||||
|
"select elapsed(ts , 1s) from (select elapsed(ts, 1s) ts from st2 group by tbname);",
|
||||||
|
"select elapsed(ts, 1s) from (select * from st1 where ts between '2023-03-01 15:00:00.000' and '2023-03-01 15:01:40.000' interval(10s) fill(next)) where c_int > 10;"
|
||||||
|
]
|
||||||
|
tdSql.errors(other_sql_list)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.prepareData()
|
||||||
|
self.test_normal_query()
|
||||||
|
self.test_query_with_filter()
|
||||||
|
self.test_query_with_other_function()
|
||||||
|
self.test_query_with_join()
|
||||||
|
self.test_query_with_union()
|
||||||
|
self.test_abnormal_query()
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -32,7 +32,7 @@
|
||||||
"childtable_prefix": "d",
|
"childtable_prefix": "d",
|
||||||
"insert_mode": "taosc",
|
"insert_mode": "taosc",
|
||||||
"timestamp_step": 30000,
|
"timestamp_step": 30000,
|
||||||
"start_timestamp":"2023-10-01 10:00:00",
|
"start_timestamp":1700000000000,
|
||||||
"columns": [
|
"columns": [
|
||||||
{ "type": "bool", "name": "bc"},
|
{ "type": "bool", "name": "bc"},
|
||||||
{ "type": "float", "name": "fc" },
|
{ "type": "float", "name": "fc" },
|
||||||
|
|
|
@ -34,23 +34,170 @@ class TDTestCase(TBase):
|
||||||
"querySmaOptimize": "1"
|
"querySmaOptimize": "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def insertData(self):
|
def insertData(self):
|
||||||
tdLog.info(f"insert data.")
|
tdLog.info(f"insert data.")
|
||||||
# taosBenchmark run
|
# taosBenchmark run
|
||||||
jfile = etool.curFile(__file__, "query_basic.json")
|
jfile = etool.curFile(__file__, "query_basic.json")
|
||||||
etool.benchMark(json=jfile)
|
etool.benchMark(json = jfile)
|
||||||
|
|
||||||
tdSql.execute(f"use {self.db}")
|
tdSql.execute(f"use {self.db}")
|
||||||
tdSql.execute("select database();")
|
tdSql.execute("select database();")
|
||||||
# set insert data information
|
# come from query_basic.json
|
||||||
self.childtable_count = 6
|
self.childtable_count = 6
|
||||||
self.insert_rows = 100000
|
self.insert_rows = 100000
|
||||||
self.timestamp_step = 30000
|
self.timestamp_step = 30000
|
||||||
|
self.start_timestamp = 1700000000000
|
||||||
|
|
||||||
|
# write again disorder
|
||||||
|
self.flushDb()
|
||||||
|
jfile = etool.curFile(__file__, "cquery_basic.json")
|
||||||
|
etool.benchMark(json = jfile)
|
||||||
|
|
||||||
|
|
||||||
|
def genTime(self, preCnt, cnt):
|
||||||
|
start = self.start_timestamp + preCnt * self.timestamp_step
|
||||||
|
end = start + self.timestamp_step * cnt
|
||||||
|
return (start, end)
|
||||||
|
|
||||||
|
|
||||||
|
def doWindowQuery(self):
|
||||||
|
pre = f"select count(ts) from {self.stb} "
|
||||||
|
# case1 operator "in" "and" is same
|
||||||
|
cnt = 6000
|
||||||
|
s,e = self.genTime(12000, cnt)
|
||||||
|
sql1 = f"{pre} where ts between {s} and {e} "
|
||||||
|
sql2 = f"{pre} where ts >= {s} and ts <={e} "
|
||||||
|
expectCnt = (cnt + 1) * self.childtable_count
|
||||||
|
tdSql.checkFirstValue(sql1, expectCnt)
|
||||||
|
tdSql.checkFirstValue(sql2, expectCnt)
|
||||||
|
|
||||||
|
# case2 no overloap "or" left
|
||||||
|
cnt1 = 120
|
||||||
|
s1, e1 = self.genTime(4000, cnt1)
|
||||||
|
cnt2 = 3000
|
||||||
|
s2, e2 = self.genTime(10000, cnt2)
|
||||||
|
sql = f"{pre} where (ts >= {s1} and ts < {e1}) or (ts >= {s2} and ts < {e2})"
|
||||||
|
expectCnt = (cnt1 + cnt2) * self.childtable_count
|
||||||
|
tdSql.checkFirstValue(sql, expectCnt)
|
||||||
|
|
||||||
|
# case3 overloap "or" right
|
||||||
|
cnt1 = 300
|
||||||
|
s1, e1 = self.genTime(17000, cnt1)
|
||||||
|
cnt2 = 8000
|
||||||
|
s2, e2 = self.genTime(70000, cnt2)
|
||||||
|
sql = f"{pre} where (ts > {s1} and ts <= {e1}) or (ts > {s2} and ts <= {e2})"
|
||||||
|
expectCnt = (cnt1 + cnt2) * self.childtable_count
|
||||||
|
tdSql.checkFirstValue(sql, expectCnt)
|
||||||
|
|
||||||
|
# case4 overloap "or"
|
||||||
|
cnt1 = 1000
|
||||||
|
s1, e1 = self.genTime(9000, cnt1)
|
||||||
|
cnt2 = 1000
|
||||||
|
s2, e2 = self.genTime(9000 + 500 , cnt2)
|
||||||
|
sql = f"{pre} where (ts > {s1} and ts <= {e1}) or (ts > {s2} and ts <= {e2})"
|
||||||
|
expectCnt = (cnt1 + 500) * self.childtable_count # expect=1500
|
||||||
|
tdSql.checkFirstValue(sql, expectCnt)
|
||||||
|
|
||||||
|
# case5 overloap "or" boundary hollow->solid
|
||||||
|
cnt1 = 3000
|
||||||
|
s1, e1 = self.genTime(45000, cnt1)
|
||||||
|
cnt2 = 2000
|
||||||
|
s2, e2 = self.genTime(45000 + cnt1 , cnt2)
|
||||||
|
sql = f"{pre} where (ts > {s1} and ts <= {e1}) or (ts > {s2} and ts <= {e2})"
|
||||||
|
expectCnt = (cnt1+cnt2) * self.childtable_count
|
||||||
|
tdSql.checkFirstValue(sql, expectCnt)
|
||||||
|
|
||||||
|
# case6 overloap "or" boundary solid->solid
|
||||||
|
cnt1 = 300
|
||||||
|
s1, e1 = self.genTime(55000, cnt1)
|
||||||
|
cnt2 = 500
|
||||||
|
s2, e2 = self.genTime(55000 + cnt1 , cnt2)
|
||||||
|
sql = f"{pre} where (ts >= {s1} and ts <= {e1}) or (ts >= {s2} and ts <= {e2})"
|
||||||
|
expectCnt = (cnt1+cnt2+1) * self.childtable_count
|
||||||
|
tdSql.checkFirstValue(sql, expectCnt)
|
||||||
|
|
||||||
|
# case7 overloap "and"
|
||||||
|
cnt1 = 1000
|
||||||
|
s1, e1 = self.genTime(40000, cnt1)
|
||||||
|
cnt2 = 1000
|
||||||
|
s2, e2 = self.genTime(40000 + 500 , cnt2)
|
||||||
|
sql = f"{pre} where (ts > {s1} and ts <= {e1}) and (ts > {s2} and ts <= {e2})"
|
||||||
|
expectCnt = cnt1/2 * self.childtable_count
|
||||||
|
tdSql.checkFirstValue(sql, expectCnt)
|
||||||
|
|
||||||
|
# case8 overloap "and" boundary hollow->solid solid->hollow
|
||||||
|
cnt1 = 3000
|
||||||
|
s1, e1 = self.genTime(45000, cnt1)
|
||||||
|
cnt2 = 2000
|
||||||
|
s2, e2 = self.genTime(45000 + cnt1 , cnt2)
|
||||||
|
sql = f"{pre} where (ts > {s1} and ts <= {e1}) and (ts >= {s2} and ts < {e2})"
|
||||||
|
expectCnt = 1 * self.childtable_count
|
||||||
|
tdSql.checkFirstValue(sql, expectCnt)
|
||||||
|
|
||||||
|
# case9 no overloap "and"
|
||||||
|
cnt1 = 6000
|
||||||
|
s1, e1 = self.genTime(20000, cnt1)
|
||||||
|
cnt2 = 300
|
||||||
|
s2, e2 = self.genTime(70000, cnt2)
|
||||||
|
sql = f"{pre} where (ts > {s1} and ts <= {e1}) and (ts >= {s2} and ts <= {e2})"
|
||||||
|
expectCnt = 0
|
||||||
|
tdSql.checkFirstValue(sql, expectCnt)
|
||||||
|
|
||||||
|
# case10 cnt1 contain cnt2 and
|
||||||
|
cnt1 = 5000
|
||||||
|
s1, e1 = self.genTime(25000, cnt1)
|
||||||
|
cnt2 = 400
|
||||||
|
s2, e2 = self.genTime(28000, cnt2)
|
||||||
|
sql = f"{pre} where (ts > {s1} and ts <= {e1}) and (ts >= {s2} and ts < {e2})"
|
||||||
|
expectCnt = cnt2 * self.childtable_count
|
||||||
|
tdSql.checkFirstValue(sql, expectCnt)
|
||||||
|
|
||||||
|
|
||||||
|
def queryMax(self, colname):
|
||||||
|
sql = f"select max({colname}) from {self.stb}"
|
||||||
|
tdSql.query(sql)
|
||||||
|
return tdSql.getData(0, 0)
|
||||||
|
|
||||||
|
|
||||||
|
def checkMax(self):
|
||||||
|
# max for tsdbRetrieveDatablockSMA2 coverage
|
||||||
|
colname = "ui"
|
||||||
|
max = self.queryMax(colname)
|
||||||
|
|
||||||
|
# insert over max
|
||||||
|
sql = f"insert into d0(ts, {colname}) values"
|
||||||
|
for i in range(1, 5):
|
||||||
|
sql += f" (now + {i}s, {max+i})"
|
||||||
|
tdSql.execute(sql)
|
||||||
|
self.flushDb()
|
||||||
|
|
||||||
|
expectMax = max + 4
|
||||||
|
for i in range(1, 5):
|
||||||
|
realMax = self.queryMax(colname)
|
||||||
|
if realMax != expectMax:
|
||||||
|
tdLog.exit(f"Max value not expect. expect:{expectMax} real:{realMax}")
|
||||||
|
|
||||||
|
# query ts list
|
||||||
|
sql = f"select ts from d0 where ui={expectMax}"
|
||||||
|
tdSql.query(sql)
|
||||||
|
tss = tdSql.getColData(0)
|
||||||
|
for ts in tss:
|
||||||
|
# delete
|
||||||
|
sql = f"delete from d0 where ts = '{ts}'"
|
||||||
|
tdSql.execute(sql)
|
||||||
|
expectMax -= 1
|
||||||
|
|
||||||
|
self.checkInsertCorrect()
|
||||||
|
|
||||||
|
|
||||||
def doQuery(self):
|
def doQuery(self):
|
||||||
tdLog.info(f"do query.")
|
tdLog.info(f"do query.")
|
||||||
|
self.doWindowQuery()
|
||||||
|
|
||||||
|
# max
|
||||||
|
self.checkMax()
|
||||||
|
|
||||||
# __group_key
|
# __group_key
|
||||||
sql = f"select count(*),_group_key(uti),uti from {self.stb} partition by uti"
|
sql = f"select count(*),_group_key(uti),uti from {self.stb} partition by uti"
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
|
@ -76,6 +223,20 @@ class TDTestCase(TBase):
|
||||||
sql2 = "select bi from stb where bi is not null order by bi desc limit 10;"
|
sql2 = "select bi from stb where bi is not null order by bi desc limit 10;"
|
||||||
self.checkSameResult(sql1, sql2)
|
self.checkSameResult(sql1, sql2)
|
||||||
|
|
||||||
|
# distributed expect values
|
||||||
|
expects = {
|
||||||
|
"Block_Rows" : 6*100000,
|
||||||
|
"Total_Tables" : 6,
|
||||||
|
"Total_Vgroups" : 3
|
||||||
|
}
|
||||||
|
self.waitTransactionZero()
|
||||||
|
reals = self.getDistributed(self.stb)
|
||||||
|
for k in expects.keys():
|
||||||
|
v = expects[k]
|
||||||
|
if int(reals[k]) != v:
|
||||||
|
tdLog.exit(f"distribute {k} expect: {v} real: {reals[k]}")
|
||||||
|
|
||||||
|
|
||||||
# run
|
# run
|
||||||
def run(self):
|
def run(self):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
|
|
@ -162,14 +162,19 @@ class AutoGen:
|
||||||
tdLog.info(f" insert data i={i}")
|
tdLog.info(f" insert data i={i}")
|
||||||
values = ""
|
values = ""
|
||||||
|
|
||||||
tdLog.info(f" insert child data {child_name} finished, insert rows={cnt}")
|
tdLog.info(f" insert child data {child_name} finished, insert rows={cnt}")
|
||||||
|
return ts
|
||||||
|
|
||||||
# insert data
|
def insert_data(self, cnt, bContinue=False):
|
||||||
def insert_data(self, cnt):
|
if not bContinue:
|
||||||
|
self.ts = 1600000000000
|
||||||
|
|
||||||
|
currTs = 1600000000000
|
||||||
for i in range(self.child_cnt):
|
for i in range(self.child_cnt):
|
||||||
name = f"{self.child_name}{i}"
|
name = f"{self.child_name}{i}"
|
||||||
self.insert_data_child(name, cnt, self.batch_size, 1)
|
currTs = self.insert_data_child(name, cnt, self.batch_size, 1)
|
||||||
|
|
||||||
|
self.ts = currTs
|
||||||
tdLog.info(f" insert data ok, child table={self.child_cnt} insert rows={cnt}")
|
tdLog.info(f" insert data ok, child table={self.child_cnt} insert rows={cnt}")
|
||||||
|
|
||||||
# insert same timestamp to all childs
|
# insert same timestamp to all childs
|
||||||
|
|
|
@ -29,7 +29,7 @@ class TBase:
|
||||||
#
|
#
|
||||||
|
|
||||||
# init
|
# init
|
||||||
def init(self, conn, logSql, replicaVar=1):
|
def init(self, conn, logSql, replicaVar=1, db="db", stb="stb", checkColName="ic"):
|
||||||
# save param
|
# save param
|
||||||
self.replicaVar = int(replicaVar)
|
self.replicaVar = int(replicaVar)
|
||||||
tdSql.init(conn.cursor(), True)
|
tdSql.init(conn.cursor(), True)
|
||||||
|
@ -41,14 +41,14 @@ class TBase:
|
||||||
self.mLevelDisk = 0
|
self.mLevelDisk = 0
|
||||||
|
|
||||||
# test case information
|
# test case information
|
||||||
self.db = "db"
|
self.db = db
|
||||||
self.stb = "stb"
|
self.stb = stb
|
||||||
|
|
||||||
# sql
|
# sql
|
||||||
self.sqlSum = f"select sum(ic) from {self.stb}"
|
self.sqlSum = f"select sum({checkColName}) from {self.stb}"
|
||||||
self.sqlMax = f"select max(ic) from {self.stb}"
|
self.sqlMax = f"select max({checkColName}) from {self.stb}"
|
||||||
self.sqlMin = f"select min(ic) from {self.stb}"
|
self.sqlMin = f"select min({checkColName}) from {self.stb}"
|
||||||
self.sqlAvg = f"select avg(ic) from {self.stb}"
|
self.sqlAvg = f"select avg({checkColName}) from {self.stb}"
|
||||||
self.sqlFirst = f"select first(ts) from {self.stb}"
|
self.sqlFirst = f"select first(ts) from {self.stb}"
|
||||||
self.sqlLast = f"select last(ts) from {self.stb}"
|
self.sqlLast = f"select last(ts) from {self.stb}"
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ class TBase:
|
||||||
tdSql.checkAgg(sql, self.childtable_count)
|
tdSql.checkAgg(sql, self.childtable_count)
|
||||||
|
|
||||||
# check step
|
# check step
|
||||||
sql = f"select * from (select diff(ts) as dif from {self.stb} partition by tbname) where dif != {self.timestamp_step}"
|
sql = f"select * from (select diff(ts) as dif from {self.stb} partition by tbname order by ts desc) where dif != {self.timestamp_step}"
|
||||||
tdSql.query(sql)
|
tdSql.query(sql)
|
||||||
tdSql.checkRows(0)
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
@ -229,9 +229,9 @@ class TBase:
|
||||||
#
|
#
|
||||||
|
|
||||||
# get vgroups
|
# get vgroups
|
||||||
def getVGroup(self, db_name):
|
def getVGroup(self, dbName):
|
||||||
vgidList = []
|
vgidList = []
|
||||||
sql = f"select vgroup_id from information_schema.ins_vgroups where db_name='{db_name}'"
|
sql = f"select vgroup_id from information_schema.ins_vgroups where db_name='{dbName}'"
|
||||||
res = tdSql.getResult(sql)
|
res = tdSql.getResult(sql)
|
||||||
rows = len(res)
|
rows = len(res)
|
||||||
for i in range(rows):
|
for i in range(rows):
|
||||||
|
@ -239,6 +239,29 @@ class TBase:
|
||||||
|
|
||||||
return vgidList
|
return vgidList
|
||||||
|
|
||||||
|
# get distributed rows
|
||||||
|
def getDistributed(self, tbName):
|
||||||
|
sql = f"show table distributed {tbName}"
|
||||||
|
tdSql.query(sql)
|
||||||
|
dics = {}
|
||||||
|
i = 0
|
||||||
|
for i in range(tdSql.getRows()):
|
||||||
|
row = tdSql.getData(i, 0)
|
||||||
|
#print(row)
|
||||||
|
row = row.replace('[', '').replace(']', '')
|
||||||
|
#print(row)
|
||||||
|
items = row.split(' ')
|
||||||
|
#print(items)
|
||||||
|
for item in items:
|
||||||
|
#print(item)
|
||||||
|
v = item.split('=')
|
||||||
|
#print(v)
|
||||||
|
if len(v) == 2:
|
||||||
|
dics[v[0]] = v[1]
|
||||||
|
if i > 5:
|
||||||
|
break
|
||||||
|
print(dics)
|
||||||
|
return dics
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -269,3 +292,15 @@ class TBase:
|
||||||
if len(lists) == 0:
|
if len(lists) == 0:
|
||||||
tdLog.exit(f"list is empty {tips}")
|
tdLog.exit(f"list is empty {tips}")
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# str util
|
||||||
|
#
|
||||||
|
# covert list to sql format string
|
||||||
|
def listSql(self, lists, sepa = ","):
|
||||||
|
strs = ""
|
||||||
|
for ls in lists:
|
||||||
|
if strs != "":
|
||||||
|
strs += sepa
|
||||||
|
strs += f"'{ls}'"
|
||||||
|
return strs
|
|
@ -13,23 +13,24 @@ from frame.common import *
|
||||||
|
|
||||||
class ClusterDnodes(TDDnodes):
|
class ClusterDnodes(TDDnodes):
|
||||||
"""rewrite TDDnodes and make MyDdnodes as TDDnodes child class"""
|
"""rewrite TDDnodes and make MyDdnodes as TDDnodes child class"""
|
||||||
def __init__(self ,dnodes_lists):
|
def __init__(self):
|
||||||
|
|
||||||
super(ClusterDnodes,self).__init__()
|
super(ClusterDnodes,self).__init__()
|
||||||
self.dnodes = dnodes_lists # dnode must be TDDnode instance
|
|
||||||
self.simDeployed = False
|
self.simDeployed = False
|
||||||
self.testCluster = False
|
self.testCluster = False
|
||||||
self.valgrind = 0
|
self.valgrind = 0
|
||||||
self.killValgrind = 1
|
self.killValgrind = 1
|
||||||
|
def init(self, dnodes_lists, deployPath, masterIp):
|
||||||
|
self.dnodes = dnodes_lists # dnode must be TDDnode instance
|
||||||
|
super(ClusterDnodes, self).init(deployPath, masterIp)
|
||||||
|
|
||||||
|
clusterDnodes = ClusterDnodes()
|
||||||
|
|
||||||
class ConfigureyCluster:
|
class ConfigureyCluster:
|
||||||
"""This will create defined number of dnodes and create a cluster.
|
"""This will create defined number of dnodes and create a cluster.
|
||||||
at the same time, it will return TDDnodes list: dnodes, """
|
at the same time, it will return TDDnodes list: dnodes, """
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.dnodes = []
|
self.dnodes = []
|
||||||
self.dnodeNums = 5
|
self.dnodeNums = 5
|
||||||
self.independent = True
|
self.independent = True
|
||||||
self.startPort = 6030
|
self.startPort = 6030
|
||||||
|
|
|
@ -251,6 +251,11 @@ class TDDnodes:
|
||||||
dnodesRootDir = "%s/sim" % (self.path)
|
dnodesRootDir = "%s/sim" % (self.path)
|
||||||
return dnodesRootDir
|
return dnodesRootDir
|
||||||
|
|
||||||
|
def getDnodeDir(self, index):
|
||||||
|
self.check(index)
|
||||||
|
dnodesDir = "%s/sim/dnode%d" % (self.path, index)
|
||||||
|
return dnodesDir
|
||||||
|
|
||||||
def getSimCfgPath(self):
|
def getSimCfgPath(self):
|
||||||
return self.sim.getCfgDir()
|
return self.sim.getCfgDir()
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,49 @@ class TDSql:
|
||||||
# do execute
|
# do execute
|
||||||
#
|
#
|
||||||
|
|
||||||
|
def errors(self, sql_list, expected_error_id_list=None, expected_error_info_list=None):
|
||||||
|
"""Execute the sql query and check the error info, expected error id or info should keep the same order with sql list,
|
||||||
|
expected_error_id_list or expected_error_info_list is None, then the error info will not be checked.
|
||||||
|
:param sql_list: the sql list to be executed.
|
||||||
|
:param expected_error_id: the expected error number.
|
||||||
|
:param expected_error_info: the expected error info.
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
if len(sql_list) > 0:
|
||||||
|
for i in range(len(sql_list)):
|
||||||
|
if expected_error_id_list and expected_error_info_list:
|
||||||
|
self.error(sql_list[i], expected_error_id_list[i], expected_error_info_list[i])
|
||||||
|
elif expected_error_id_list:
|
||||||
|
self.error(sql_list[i], expectedErrno=expected_error_id_list[i])
|
||||||
|
elif expected_error_info_list:
|
||||||
|
self.error(sql_list[i], expectErrInfo=expected_error_info_list[i])
|
||||||
|
else:
|
||||||
|
self.error(sql_list[i])
|
||||||
|
else:
|
||||||
|
tdLog.exit("sql list is empty")
|
||||||
|
except Exception as ex:
|
||||||
|
tdLog.exit("Failed to execute sql list: %s, error: %s" % (sql_list, ex))
|
||||||
|
|
||||||
|
def queryAndCheckResult(self, sql_list, expect_result_list):
|
||||||
|
"""Execute the sql query and check the result.
|
||||||
|
:param sql_list: the sql list to be executed.
|
||||||
|
:param expect_result_list: the expected result list.
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
for index in range(len(sql_list)):
|
||||||
|
self.query(sql_list[index])
|
||||||
|
if len(expect_result_list[index]) == 0:
|
||||||
|
self.checkRows(0)
|
||||||
|
else:
|
||||||
|
self.checkRows(len(expect_result_list[index]))
|
||||||
|
for row in range(len(expect_result_list[index])):
|
||||||
|
for col in range(len(expect_result_list[index][row])):
|
||||||
|
self.checkData(row, col, expect_result_list[index][row][col])
|
||||||
|
except Exception as ex:
|
||||||
|
raise(ex)
|
||||||
|
|
||||||
def query(self, sql, row_tag=None, queryTimes=10, count_expected_res=None):
|
def query(self, sql, row_tag=None, queryTimes=10, count_expected_res=None):
|
||||||
self.sql = sql
|
self.sql = sql
|
||||||
i=1
|
i=1
|
||||||
|
@ -223,6 +266,12 @@ class TDSql:
|
||||||
def getData(self, row, col):
|
def getData(self, row, col):
|
||||||
self.checkRowCol(row, col)
|
self.checkRowCol(row, col)
|
||||||
return self.res[row][col]
|
return self.res[row][col]
|
||||||
|
|
||||||
|
def getColData(self, col):
|
||||||
|
colDatas = []
|
||||||
|
for i in range(self.queryRows):
|
||||||
|
colDatas.append(self.res[i][col])
|
||||||
|
return colDatas
|
||||||
|
|
||||||
def getResult(self, sql):
|
def getResult(self, sql):
|
||||||
self.sql = sql
|
self.sql = sql
|
||||||
|
@ -441,6 +490,48 @@ class TDSql:
|
||||||
if(show):
|
if(show):
|
||||||
tdLog.info("check successfully")
|
tdLog.info("check successfully")
|
||||||
|
|
||||||
|
def checkDataMem(self, mem):
|
||||||
|
if not isinstance(mem, list):
|
||||||
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
|
args = (caller.filename, caller.lineno, self.sql)
|
||||||
|
tdLog.exit("%s(%d) failed: sql:%s, expect data is error, must is array[][]" % args)
|
||||||
|
|
||||||
|
if len(mem) != self.queryRows:
|
||||||
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
|
args = (caller.filename, caller.lineno, self.sql, len(mem), self.queryRows)
|
||||||
|
tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args)
|
||||||
|
# row, col, data
|
||||||
|
for row, rowData in enumerate(mem):
|
||||||
|
for col, colData in enumerate(rowData):
|
||||||
|
self.checkData(row, col, colData)
|
||||||
|
tdLog.info("check successfully")
|
||||||
|
|
||||||
|
def checkDataCsv(self, csvfilePath):
|
||||||
|
if not isinstance(csvfilePath, str) or len(csvfilePath) == 0:
|
||||||
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
|
args = (caller.filename, caller.lineno, self.sql, csvfilePath)
|
||||||
|
tdLog.exit("%s(%d) failed: sql:%s, expect csvfile path error:%s" % args)
|
||||||
|
|
||||||
|
tdLog.info("read csvfile read begin")
|
||||||
|
data = []
|
||||||
|
try:
|
||||||
|
with open(csvfilePath) as csvfile:
|
||||||
|
csv_reader = csv.reader(csvfile) # csv.reader read csvfile\
|
||||||
|
# header = next(csv_reader) # Read the header of each column in the first row
|
||||||
|
for row in csv_reader: # csv file save to data
|
||||||
|
data.append(row)
|
||||||
|
except FileNotFoundError:
|
||||||
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
|
args = (caller.filename, caller.lineno, self.sql, csvfilePath)
|
||||||
|
tdLog.exit("%s(%d) failed: sql:%s, expect csvfile not find error:%s" % args)
|
||||||
|
except Exception as e:
|
||||||
|
caller = inspect.getframeinfo(inspect.stack()[1][0])
|
||||||
|
args = (caller.filename, caller.lineno, self.sql, csvfilePath, str(e))
|
||||||
|
tdLog.exit("%s(%d) failed: sql:%s, expect csvfile path:%s, read error:%s" % args)
|
||||||
|
|
||||||
|
tdLog.info("read csvfile read successfully")
|
||||||
|
self.checkDataMem(data)
|
||||||
|
|
||||||
# return true or false replace exit, no print out
|
# return true or false replace exit, no print out
|
||||||
def checkRowColNoExit(self, row, col):
|
def checkRowColNoExit(self, row, col):
|
||||||
caller = inspect.getframeinfo(inspect.stack()[2][0])
|
caller = inspect.getframeinfo(inspect.stack()[2][0])
|
||||||
|
|
|
@ -405,15 +405,15 @@ if __name__ == "__main__":
|
||||||
else :
|
else :
|
||||||
tdLog.debug("create an cluster with %s nodes and make %s dnode as independent mnode"%(dnodeNums,mnodeNums))
|
tdLog.debug("create an cluster with %s nodes and make %s dnode as independent mnode"%(dnodeNums,mnodeNums))
|
||||||
dnodeslist = cluster.configure_cluster(dnodeNums=dnodeNums, mnodeNums=mnodeNums, independentMnode=independentMnode, level=level, disk=disk)
|
dnodeslist = cluster.configure_cluster(dnodeNums=dnodeNums, mnodeNums=mnodeNums, independentMnode=independentMnode, level=level, disk=disk)
|
||||||
tdDnodes = ClusterDnodes(dnodeslist)
|
clusterDnodes.init(dnodeslist, deployPath, masterIp)
|
||||||
tdDnodes.init(deployPath, masterIp)
|
clusterDnodes.setTestCluster(testCluster)
|
||||||
tdDnodes.setTestCluster(testCluster)
|
clusterDnodes.setValgrind(valgrind)
|
||||||
tdDnodes.setValgrind(valgrind)
|
clusterDnodes.setAsan(asan)
|
||||||
tdDnodes.stopAll()
|
clusterDnodes.stopAll()
|
||||||
for dnode in tdDnodes.dnodes:
|
for dnode in clusterDnodes.dnodes:
|
||||||
tdDnodes.deploy(dnode.index, updateCfgDict)
|
clusterDnodes.deploy(dnode.index, updateCfgDict)
|
||||||
for dnode in tdDnodes.dnodes:
|
for dnode in clusterDnodes.dnodes:
|
||||||
tdDnodes.starttaosd(dnode.index)
|
clusterDnodes.starttaosd(dnode.index)
|
||||||
tdCases.logSql(logSql)
|
tdCases.logSql(logSql)
|
||||||
|
|
||||||
if restful or websocket:
|
if restful or websocket:
|
||||||
|
@ -580,16 +580,15 @@ if __name__ == "__main__":
|
||||||
print(independentMnode,"independentMnode valuse")
|
print(independentMnode,"independentMnode valuse")
|
||||||
# create dnode list
|
# create dnode list
|
||||||
dnodeslist = cluster.configure_cluster(dnodeNums=dnodeNums, mnodeNums=mnodeNums, independentMnode=independentMnode, level=level, disk=disk)
|
dnodeslist = cluster.configure_cluster(dnodeNums=dnodeNums, mnodeNums=mnodeNums, independentMnode=independentMnode, level=level, disk=disk)
|
||||||
tdDnodes = ClusterDnodes(dnodeslist)
|
clusterDnodes.init(dnodeslist, deployPath, masterIp)
|
||||||
tdDnodes.init(deployPath, masterIp)
|
clusterDnodes.setTestCluster(testCluster)
|
||||||
tdDnodes.setTestCluster(testCluster)
|
clusterDnodes.setValgrind(valgrind)
|
||||||
tdDnodes.setValgrind(valgrind)
|
clusterDnodes.setAsan(asan)
|
||||||
tdDnodes.setAsan(asan)
|
clusterDnodes.stopAll()
|
||||||
tdDnodes.stopAll()
|
for dnode in clusterDnodes.dnodes:
|
||||||
for dnode in tdDnodes.dnodes:
|
clusterDnodes.deploy(dnode.index,updateCfgDict)
|
||||||
tdDnodes.deploy(dnode.index,updateCfgDict)
|
for dnode in clusterDnodes.dnodes:
|
||||||
for dnode in tdDnodes.dnodes:
|
clusterDnodes.starttaosd(dnode.index)
|
||||||
tdDnodes.starttaosd(dnode.index)
|
|
||||||
tdCases.logSql(logSql)
|
tdCases.logSql(logSql)
|
||||||
|
|
||||||
if restful or websocket:
|
if restful or websocket:
|
||||||
|
|
|
@ -17,10 +17,15 @@ fi
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f enterprise/multi-level/mlevel_basic.py -N 3 -L 3 -D 2
|
,,y,army,./pytest.sh python3 ./test.py -f enterprise/multi-level/mlevel_basic.py -N 3 -L 3 -D 2
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f enterprise/s3/s3_basic.py -L 3 -D 1
|
,,y,army,./pytest.sh python3 ./test.py -f enterprise/s3/s3_basic.py -L 3 -D 1
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f community/cluster/snapshot.py -N 3 -L 3 -D 2
|
,,y,army,./pytest.sh python3 ./test.py -f community/cluster/snapshot.py -N 3 -L 3 -D 2
|
||||||
|
,,y,army,./pytest.sh python3 ./test.py -f community/query/function/test_func_elapsed.py
|
||||||
|
,,y,army,./pytest.sh python3 ./test.py -f community/query/fill/fill_desc.py -N 3 -L 3 -D 2
|
||||||
|
,,y,army,./pytest.sh python3 ./test.py -f community/cluster/incSnapshot.py -N 3 -L 3 -D 2
|
||||||
,,y,army,./pytest.sh python3 ./test.py -f community/query/query_basic.py -N 3
|
,,y,army,./pytest.sh python3 ./test.py -f community/query/query_basic.py -N 3
|
||||||
|
|
||||||
,,n,army,python3 ./test.py -f community/cmdline/fullopt.py
|
,,n,army,python3 ./test.py -f community/cmdline/fullopt.py
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# system test
|
# system test
|
||||||
#
|
#
|
||||||
|
@ -43,6 +48,7 @@ fi
|
||||||
#,,n,system-test,python3 ./test.py -f 8-stream/snode_restart.py -N 4
|
#,,n,system-test,python3 ./test.py -f 8-stream/snode_restart.py -N 4
|
||||||
,,n,system-test,python3 ./test.py -f 8-stream/snode_restart_with_checkpoint.py -N 4
|
,,n,system-test,python3 ./test.py -f 8-stream/snode_restart_with_checkpoint.py -N 4
|
||||||
|
|
||||||
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/partition_expr.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/project_group.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/project_group.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tbname_vgroup.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tbname_vgroup.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count_interval.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count_interval.py
|
||||||
|
@ -231,10 +237,14 @@ fi
|
||||||
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select-duplicatedata.py -N 3 -n 3
|
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select-duplicatedata.py -N 3 -n 3
|
||||||
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select-duplicatedata-false.py -N 3 -n 3
|
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select-duplicatedata-false.py -N 3 -n 3
|
||||||
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select.py -N 3 -n 3
|
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select.py -N 3 -n 3
|
||||||
|
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-stb-select-false.py -N 3 -n 3
|
||||||
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-stb.py -N 3 -n 3
|
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-stb.py -N 3 -n 3
|
||||||
|
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-stb-false.py -N 3 -n 3
|
||||||
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-column.py -N 3 -n 3
|
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-column.py -N 3 -n 3
|
||||||
|
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-column-false.py -N 3 -n 3
|
||||||
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-db.py -N 3 -n 3
|
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-db.py -N 3 -n 3
|
||||||
e
|
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeSplit-db-false.py -N 3 -n 3
|
||||||
|
|
||||||
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeReplicate.py -M 3 -N 3 -n 3
|
,,y,system-test,./pytest.sh python3 test.py -f 7-tmq/tmqVnodeReplicate.py -M 3 -N 3 -n 3
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-19201.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-19201.py
|
||||||
,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py
|
,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
{
|
||||||
|
"filetype": "insert",
|
||||||
|
"cfgdir": "/etc/taos",
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"port": 6030,
|
||||||
|
"user": "root",
|
||||||
|
"password": "taosdata",
|
||||||
|
"connection_pool_size": 8,
|
||||||
|
"num_of_records_per_req": 2000,
|
||||||
|
"thread_count": 2,
|
||||||
|
"create_table_thread_count": 10,
|
||||||
|
"result_file": "./insert_res_mix.txt",
|
||||||
|
"confirm_parameter_prompt": "no",
|
||||||
|
"insert_interval": 0,
|
||||||
|
"check_sql": "yes",
|
||||||
|
"continue_if_fail": "yes",
|
||||||
|
"databases": [
|
||||||
|
{
|
||||||
|
"dbinfo": {
|
||||||
|
"name": "curdb",
|
||||||
|
"drop": "yes",
|
||||||
|
"vgroups": 2,
|
||||||
|
"replica": 1,
|
||||||
|
"precision": "ms",
|
||||||
|
"stt_trigger": 8,
|
||||||
|
"minRows": 100,
|
||||||
|
"maxRows": 4096
|
||||||
|
},
|
||||||
|
"super_tables": [
|
||||||
|
{
|
||||||
|
"name": "meters",
|
||||||
|
"child_table_exists": "no",
|
||||||
|
"childtable_count": 5,
|
||||||
|
"insert_rows": 100000,
|
||||||
|
"childtable_prefix": "d",
|
||||||
|
"insert_mode": "taosc",
|
||||||
|
"insert_interval": 0,
|
||||||
|
"timestamp_step": 1000,
|
||||||
|
"start_timestamp":"2022-09-01 10:00:00",
|
||||||
|
"disorder_ratio": 60,
|
||||||
|
"update_ratio": 70,
|
||||||
|
"delete_ratio": 30,
|
||||||
|
"disorder_fill_interval": 300,
|
||||||
|
"update_fill_interval": 25,
|
||||||
|
"generate_row_rule": 2,
|
||||||
|
"columns": [
|
||||||
|
{ "type": "bool", "name": "bc"},
|
||||||
|
{ "type": "float", "name": "fc", "max": 1, "min": 0 },
|
||||||
|
{ "type": "double", "name": "dc", "max": 1, "min": 0 },
|
||||||
|
{ "type": "tinyint", "name": "ti", "max": 100, "min": 0 },
|
||||||
|
{ "type": "smallint", "name": "si", "max": 100, "min": 0 },
|
||||||
|
{ "type": "int", "name": "ic", "max": 100, "min": 0 },
|
||||||
|
{ "type": "bigint", "name": "bi", "max": 100, "min": 0 },
|
||||||
|
{ "type": "utinyint", "name": "uti", "max": 100, "min": 0 },
|
||||||
|
{ "type": "usmallint", "name": "usi", "max": 100, "min": 0 },
|
||||||
|
{ "type": "uint", "name": "ui", "max": 100, "min": 0 },
|
||||||
|
{ "type": "ubigint", "name": "ubi", "max": 100, "min": 0 },
|
||||||
|
{ "type": "binary", "name": "bin", "len": 32},
|
||||||
|
{ "type": "nchar", "name": "nch", "len": 64}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"type": "tinyint",
|
||||||
|
"name": "groupid",
|
||||||
|
"max": 10,
|
||||||
|
"min": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "location",
|
||||||
|
"type": "binary",
|
||||||
|
"len": 16,
|
||||||
|
"values": ["San Francisco", "Los Angles", "San Diego",
|
||||||
|
"San Jose", "Palo Alto", "Campbell", "Mountain View",
|
||||||
|
"Sunnyvale", "Santa Clara", "Cupertino"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -152,6 +152,13 @@ class TDTestCase:
|
||||||
tdLog.info(f" LD_LIBRARY_PATH=/usr/lib taosBenchmark -t {tableNumbers} -n {recordNumbers1} -y ")
|
tdLog.info(f" LD_LIBRARY_PATH=/usr/lib taosBenchmark -t {tableNumbers} -n {recordNumbers1} -y ")
|
||||||
os.system(f"LD_LIBRARY_PATH=/usr/lib taosBenchmark -t {tableNumbers} -n {recordNumbers1} -y ")
|
os.system(f"LD_LIBRARY_PATH=/usr/lib taosBenchmark -t {tableNumbers} -n {recordNumbers1} -y ")
|
||||||
os.system("LD_LIBRARY_PATH=/usr/lib taos -s 'flush database test '")
|
os.system("LD_LIBRARY_PATH=/usr/lib taos -s 'flush database test '")
|
||||||
|
os.system("LD_LIBRARY_PATH=/usr/lib taosBenchmark -f 0-others/com_alltypedata.json -y")
|
||||||
|
os.system("LD_LIBRARY_PATH=/usr/lib taos -s 'flush database curdb '")
|
||||||
|
os.system("LD_LIBRARY_PATH=/usr/lib taos -s 'select count(*) from curdb.meters '")
|
||||||
|
os.system("LD_LIBRARY_PATH=/usr/lib taos -s 'select sum(fc) from curdb.meters '")
|
||||||
|
os.system("LD_LIBRARY_PATH=/usr/lib taos -s 'select avg(ic) from curdb.meters '")
|
||||||
|
os.system("LD_LIBRARY_PATH=/usr/lib taos -s 'select min(ui) from curdb.meters '")
|
||||||
|
os.system("LD_LIBRARY_PATH=/usr/lib taos -s 'select max(bi) from curdb.meters '")
|
||||||
|
|
||||||
# os.system(f"LD_LIBRARY_PATH=/usr/lib taos -s 'use test;create stream current_stream into current_stream_output_stb as select _wstart as `start`, _wend as wend, max(current) as max_current from meters where voltage <= 220 interval (5s);' ")
|
# os.system(f"LD_LIBRARY_PATH=/usr/lib taos -s 'use test;create stream current_stream into current_stream_output_stb as select _wstart as `start`, _wend as wend, max(current) as max_current from meters where voltage <= 220 interval (5s);' ")
|
||||||
# os.system('LD_LIBRARY_PATH=/usr/lib taos -s "use test;create stream power_stream into power_stream_output_stb as select ts, concat_ws(\\".\\", location, tbname) as meter_location, current*voltage*cos(phase) as active_power, current*voltage*sin(phase) as reactive_power from meters partition by tbname;" ')
|
# os.system('LD_LIBRARY_PATH=/usr/lib taos -s "use test;create stream power_stream into power_stream_output_stb as select ts, concat_ws(\\".\\", location, tbname) as meter_location, current*voltage*cos(phase) as active_power, current*voltage*sin(phase) as reactive_power from meters partition by tbname;" ')
|
||||||
|
|
|
@ -0,0 +1,275 @@
|
||||||
|
from urllib.parse import uses_relative
|
||||||
|
import taos
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import platform
|
||||||
|
import inspect
|
||||||
|
from taos.tmq import Consumer
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.dnodes import *
|
||||||
|
from util.dnodes import TDDnodes
|
||||||
|
from util.dnodes import TDDnode
|
||||||
|
from util.cluster import *
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
BASEVERSION = "3.0.2.3"
|
||||||
|
class TDTestCase:
|
||||||
|
def caseDescription(self):
|
||||||
|
f'''
|
||||||
|
3.0 data compatibility test
|
||||||
|
case1: basedata version is {BASEVERSION}
|
||||||
|
'''
|
||||||
|
return
|
||||||
|
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
self.deletedDataSql= '''drop database if exists deldata;create database deldata duration 300 stt_trigger 1; ;use deldata;
|
||||||
|
create table deldata.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);
|
||||||
|
create table deldata.ct1 using deldata.stb1 tags ( 1 );
|
||||||
|
insert into deldata.ct1 values ( now()-0s, 0, 0, 0, 0, 0.0, 0.0, 0, 'binary0', 'nchar0', now()+0a ) ( now()-10s, 1, 11111, 111, 11, 1.11, 11.11, 1, 'binary1', 'nchar1', now()+1a ) ( now()-20s, 2, 22222, 222, 22, 2.22, 22.22, 0, 'binary2', 'nchar2', now()+2a ) ( now()-30s, 3, 33333, 333, 33, 3.33, 33.33, 1, 'binary3', 'nchar3', now()+3a );
|
||||||
|
select avg(c1) from deldata.ct1;
|
||||||
|
delete from deldata.stb1;
|
||||||
|
flush database deldata;
|
||||||
|
insert into deldata.ct1 values ( now()-0s, 0, 0, 0, 0, 0.0, 0.0, 0, 'binary0', 'nchar0', now()+0a ) ( now()-10s, 1, 11111, 111, 11, 1.11, 11.11, 1, 'binary1', 'nchar1', now()+1a ) ( now()-20s, 2, 22222, 222, 22, 2.22, 22.22, 0, 'binary2', 'nchar2', now()+2a ) ( now()-30s, 3, 33333, 333, 33, 3.33, 33.33, 1, 'binary3', 'nchar3', now()+3a );
|
||||||
|
delete from deldata.ct1;
|
||||||
|
insert into deldata.ct1 values ( now()-0s, 0, 0, 0, 0, 0.0, 0.0, 0, 'binary0', 'nchar0', now()+0a );
|
||||||
|
flush database deldata;'''
|
||||||
|
def checkProcessPid(self,processName):
|
||||||
|
i=0
|
||||||
|
while i<60:
|
||||||
|
print(f"wait stop {processName}")
|
||||||
|
processPid = subprocess.getstatusoutput(f'ps aux|grep {processName} |grep -v "grep"|awk \'{{print $2}}\'')[1]
|
||||||
|
print(f"times:{i},{processName}-pid:{processPid}")
|
||||||
|
if(processPid == ""):
|
||||||
|
break
|
||||||
|
i += 1
|
||||||
|
sleep(1)
|
||||||
|
else:
|
||||||
|
print(f'this processName is not stoped in 60s')
|
||||||
|
|
||||||
|
|
||||||
|
def getBuildPath(self):
|
||||||
|
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
if ("community" in selfPath):
|
||||||
|
projPath = selfPath[:selfPath.find("community")]
|
||||||
|
else:
|
||||||
|
projPath = selfPath[:selfPath.find("tests")]
|
||||||
|
|
||||||
|
self.projPath = projPath
|
||||||
|
for root, dirs, files in os.walk(projPath):
|
||||||
|
if ("taosd" in files or "taosd.exe" in files):
|
||||||
|
rootRealPath = os.path.dirname(os.path.realpath(root))
|
||||||
|
if ("packaging" not in rootRealPath):
|
||||||
|
buildPath = root[:len(root)-len("/build/bin")]
|
||||||
|
break
|
||||||
|
return buildPath
|
||||||
|
|
||||||
|
def getCfgPath(self):
|
||||||
|
buildPath = self.getBuildPath()
|
||||||
|
selfPath = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
if ("community" in selfPath):
|
||||||
|
cfgPath = buildPath + "/../sim/dnode1/cfg/"
|
||||||
|
else:
|
||||||
|
cfgPath = buildPath + "/../sim/dnode1/cfg/"
|
||||||
|
|
||||||
|
return cfgPath
|
||||||
|
|
||||||
|
def installTaosd(self,bPath,cPath):
|
||||||
|
# os.system(f"rmtaos && mkdir -p {self.getBuildPath()}/build/lib/temp && mv {self.getBuildPath()}/build/lib/libtaos.so* {self.getBuildPath()}/build/lib/temp/ ")
|
||||||
|
# os.system(f" mv {bPath}/build {bPath}/build_bak ")
|
||||||
|
# os.system(f"mv {self.getBuildPath()}/build/lib/libtaos.so {self.getBuildPath()}/build/lib/libtaos.so_bak ")
|
||||||
|
# os.system(f"mv {self.getBuildPath()}/build/lib/libtaos.so.1 {self.getBuildPath()}/build/lib/libtaos.so.1_bak ")
|
||||||
|
|
||||||
|
packagePath = "/usr/local/src/"
|
||||||
|
dataPath = cPath + "/../data/"
|
||||||
|
if platform.system() == "Linux" and platform.machine() == "aarch64":
|
||||||
|
packageName = "TDengine-server-"+ BASEVERSION + "-Linux-arm64.tar.gz"
|
||||||
|
else:
|
||||||
|
packageName = "TDengine-server-"+ BASEVERSION + "-Linux-x64.tar.gz"
|
||||||
|
packageTPath = packageName.split("-Linux-")[0]
|
||||||
|
my_file = Path(f"{packagePath}/{packageName}")
|
||||||
|
if not my_file.exists():
|
||||||
|
print(f"{packageName} is not exists")
|
||||||
|
tdLog.info(f"cd {packagePath} && wget https://www.tdengine.com/assets-download/3.0/{packageName}")
|
||||||
|
os.system(f"cd {packagePath} && wget https://www.tdengine.com/assets-download/3.0/{packageName}")
|
||||||
|
else:
|
||||||
|
print(f"{packageName} has been exists")
|
||||||
|
os.system(f" cd {packagePath} && tar xvf {packageName} && cd {packageTPath} && ./install.sh -e no " )
|
||||||
|
tdDnodes.stop(1)
|
||||||
|
print(f"start taosd: rm -rf {dataPath}/* && nohup taosd -c {cPath} & ")
|
||||||
|
os.system(f"rm -rf {dataPath}/* && nohup taosd -c {cPath} & " )
|
||||||
|
sleep(5)
|
||||||
|
|
||||||
|
|
||||||
|
def buildTaosd(self,bPath):
|
||||||
|
# os.system(f"mv {bPath}/build_bak {bPath}/build ")
|
||||||
|
os.system(f" cd {bPath} ")
|
||||||
|
|
||||||
|
def is_list_same_as_ordered_list(self,unordered_list, ordered_list):
|
||||||
|
sorted_list = sorted(unordered_list)
|
||||||
|
return sorted_list == ordered_list
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
scriptsPath = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
distro_id = distro.id()
|
||||||
|
if distro_id == "alpine":
|
||||||
|
tdLog.info(f"alpine skip compatibility test")
|
||||||
|
return True
|
||||||
|
if platform.system().lower() == 'windows':
|
||||||
|
tdLog.info(f"Windows skip compatibility test")
|
||||||
|
return True
|
||||||
|
bPath = self.getBuildPath()
|
||||||
|
cPath = self.getCfgPath()
|
||||||
|
dbname = "test"
|
||||||
|
stb = f"{dbname}.meters"
|
||||||
|
os.system("echo 'debugFlag 143' > /etc/taos/taos.cfg ")
|
||||||
|
tableNumbers=100
|
||||||
|
recordNumbers1=100
|
||||||
|
recordNumbers2=1000
|
||||||
|
|
||||||
|
# tdsqlF=tdCom.newTdSql()
|
||||||
|
# print(tdsqlF)
|
||||||
|
# tdsqlF.query(f"SELECT SERVER_VERSION();")
|
||||||
|
# print(tdsqlF.query(f"SELECT SERVER_VERSION();"))
|
||||||
|
# oldServerVersion=tdsqlF.queryResult[0][0]
|
||||||
|
# tdLog.info(f"Base server version is {oldServerVersion}")
|
||||||
|
# tdsqlF.query(f"SELECT CLIENT_VERSION();")
|
||||||
|
# # the oldClientVersion can't be updated in the same python process,so the version is new compiled verison
|
||||||
|
# oldClientVersion=tdsqlF.queryResult[0][0]
|
||||||
|
# tdLog.info(f"Base client version is {oldClientVersion}")
|
||||||
|
# baseVersion = "3.0.1.8"
|
||||||
|
|
||||||
|
tdLog.printNoPrefix(f"==========step1:prepare and check data in old version-{BASEVERSION}")
|
||||||
|
os.system(f"rm -rf {cPath}/../data")
|
||||||
|
print(self.projPath)
|
||||||
|
# this data file is special for coverage test in 192.168.1.96
|
||||||
|
os.system("cp -r f{self.projPath}/../comp_testdata/data/ {self.projPath}/sim/dnode1")
|
||||||
|
tdDnodes.stop(1)
|
||||||
|
tdDnodes.start(1)
|
||||||
|
|
||||||
|
|
||||||
|
tdsql=tdCom.newTdSql()
|
||||||
|
tdsql.query(f"SELECT SERVER_VERSION();")
|
||||||
|
nowServerVersion=tdsql.queryResult[0][0]
|
||||||
|
tdLog.printNoPrefix(f"==========step3:prepare and check data in new version-{nowServerVersion}")
|
||||||
|
tdsql.query(f"select count(*) from {stb}")
|
||||||
|
tdsql.checkData(0,0,tableNumbers*recordNumbers1)
|
||||||
|
# tdsql.query("show streams;")
|
||||||
|
# os.system(f"taosBenchmark -t {tableNumbers} -n {recordNumbers2} -y ")
|
||||||
|
# tdsql.query("show streams;")
|
||||||
|
# tdsql.query(f"select count(*) from {stb}")
|
||||||
|
# tdsql.checkData(0,0,tableNumbers*recordNumbers2)
|
||||||
|
|
||||||
|
# checkout db4096
|
||||||
|
tdsql.query("select count(*) from db4096.stb0")
|
||||||
|
tdsql.checkData(0,0,50000)
|
||||||
|
|
||||||
|
# checkout deleted data
|
||||||
|
tdsql.execute("insert into deldata.ct1 values ( now()-0s, 0, 0, 0, 0, 0.0, 0.0, 0, 'binary0', 'nchar0', now()+0a ) ( now()-10s, 1, 11111, 111, 11, 1.11, 11.11, 1, 'binary1', 'nchar1', now()+1a ) ( now()-20s, 2, 22222, 222, 22, 2.22, 22.22, 0, 'binary2', 'nchar2', now()+2a ) ( now()-30s, 3, 33333, 333, 33, 3.33, 33.33, 1, 'binary3', 'nchar3', now()+3a );")
|
||||||
|
tdsql.execute("flush database deldata;")
|
||||||
|
tdsql.query("select avg(c1) from deldata.ct1;")
|
||||||
|
|
||||||
|
|
||||||
|
tdsql=tdCom.newTdSql()
|
||||||
|
tdLog.printNoPrefix("==========step4:verify backticks in taos Sql-TD18542")
|
||||||
|
tdsql.execute("drop database if exists db")
|
||||||
|
tdsql.execute("create database db")
|
||||||
|
tdsql.execute("use db")
|
||||||
|
tdsql.execute("create stable db.stb1 (ts timestamp, c1 int) tags (t1 int);")
|
||||||
|
tdsql.execute("insert into db.ct1 using db.stb1 TAGS(1) values(now(),11);")
|
||||||
|
tdsql.error(" insert into `db.ct2` using db.stb1 TAGS(9) values(now(),11);")
|
||||||
|
tdsql.error(" insert into db.`db.ct2` using db.stb1 TAGS(9) values(now(),11);")
|
||||||
|
tdsql.execute("insert into `db`.ct3 using db.stb1 TAGS(3) values(now(),13);")
|
||||||
|
tdsql.query("select * from db.ct3")
|
||||||
|
tdsql.checkData(0,1,13)
|
||||||
|
tdsql.execute("insert into db.`ct4` using db.stb1 TAGS(4) values(now(),14);")
|
||||||
|
tdsql.query("select * from db.ct4")
|
||||||
|
tdsql.checkData(0,1,14)
|
||||||
|
|
||||||
|
#check retentions
|
||||||
|
tdsql=tdCom.newTdSql()
|
||||||
|
tdsql.query("describe information_schema.ins_databases;")
|
||||||
|
qRows=tdsql.queryRows
|
||||||
|
comFlag=True
|
||||||
|
j=0
|
||||||
|
while comFlag:
|
||||||
|
for i in range(qRows) :
|
||||||
|
if tdsql.queryResult[i][0] == "retentions" :
|
||||||
|
print("parameters include retentions")
|
||||||
|
comFlag=False
|
||||||
|
break
|
||||||
|
else :
|
||||||
|
comFlag=True
|
||||||
|
j=j+1
|
||||||
|
if j == qRows:
|
||||||
|
print("parameters don't include retentions")
|
||||||
|
caller = inspect.getframeinfo(inspect.stack()[0][0])
|
||||||
|
args = (caller.filename, caller.lineno)
|
||||||
|
tdLog.exit("%s(%d) failed" % args)
|
||||||
|
|
||||||
|
# check stream
|
||||||
|
tdsql.query("show streams;")
|
||||||
|
tdsql.checkRows(0)
|
||||||
|
|
||||||
|
#check TS-3131
|
||||||
|
tdsql.query("select *,tbname from d0.almlog where mcid='m0103';")
|
||||||
|
tdsql.checkRows(6)
|
||||||
|
expectList = [0,3003,20031,20032,20033,30031]
|
||||||
|
resultList = []
|
||||||
|
for i in range(6):
|
||||||
|
resultList.append(tdsql.queryResult[i][3])
|
||||||
|
print(resultList)
|
||||||
|
if self.is_list_same_as_ordered_list(resultList,expectList):
|
||||||
|
print("The unordered list is the same as the ordered list.")
|
||||||
|
else:
|
||||||
|
tdLog.exit("The unordered list is not the same as the ordered list.")
|
||||||
|
tdsql.execute("insert into test.d80 values (now+1s, 11, 103, 0.21);")
|
||||||
|
tdsql.execute("insert into test.d9 values (now+5s, 4.3, 104, 0.4);")
|
||||||
|
|
||||||
|
|
||||||
|
# check tmq
|
||||||
|
conn = taos.connect()
|
||||||
|
|
||||||
|
consumer = Consumer(
|
||||||
|
{
|
||||||
|
"group.id": "tg75",
|
||||||
|
"client.id": "124",
|
||||||
|
"td.connect.user": "root",
|
||||||
|
"td.connect.pass": "taosdata",
|
||||||
|
"enable.auto.commit": "true",
|
||||||
|
"experimental.snapshot.enable": "true",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
consumer.subscribe(["tmq_test_topic"])
|
||||||
|
|
||||||
|
while True:
|
||||||
|
res = consumer.poll(10)
|
||||||
|
if not res:
|
||||||
|
break
|
||||||
|
err = res.error()
|
||||||
|
if err is not None:
|
||||||
|
raise err
|
||||||
|
val = res.value()
|
||||||
|
|
||||||
|
for block in val:
|
||||||
|
print(block.fetchall())
|
||||||
|
tdsql.query("show topics;")
|
||||||
|
tdsql.checkRows(1)
|
||||||
|
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -168,8 +168,37 @@ class TDTestCase:
|
||||||
tdSql.query(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9;")
|
tdSql.query(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9;")
|
||||||
tdSql.checkRows(nonempty_tb_num)
|
tdSql.checkRows(nonempty_tb_num)
|
||||||
|
|
||||||
|
def test_event_window(self, nonempty_tb_num):
|
||||||
|
tdSql.query(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9 and 1=1;")
|
||||||
|
tdSql.checkRows(nonempty_tb_num)
|
||||||
|
|
||||||
|
tdSql.query(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9 and 1=0;")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
tdSql.query(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9 and tbname='sub_{self.stable}_0';")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
|
tdSql.query(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9 and t2=0;")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
|
tdSql.query(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9 and _rowts>0;")
|
||||||
|
tdSql.checkRows(nonempty_tb_num)
|
||||||
|
|
||||||
|
tdSql.query(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9 and _qstart>0;")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
tdSql.query(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9 and _qstart<0;")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
tdSql.query(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9 and _qstart<_qend;")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
|
||||||
|
tdSql.error(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9 and _wstart<q_start;")
|
||||||
|
tdSql.error(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9 and _wstart - q_start > 0;")
|
||||||
|
tdSql.error(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9 and _irowts>0;")
|
||||||
|
tdSql.error(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 and _wduration > 5s end with c2 = 9;")
|
||||||
|
tdSql.error(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9 and _wstart > 1299845454;")
|
||||||
|
tdSql.error(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9 and _wduration + 1s > 5s;")
|
||||||
|
tdSql.error(f"select tbname, count(*) from {self.dbname}.{self.stable} partition by tbname event_window start with c1 >= 0 end with c2 = 9 and count(*) > 10;")
|
||||||
|
|
||||||
|
|
||||||
def test_error(self):
|
def test_error(self):
|
||||||
tdSql.error(f"select * from {self.dbname}.{self.stable} group by t2")
|
tdSql.error(f"select * from {self.dbname}.{self.stable} group by t2")
|
||||||
tdSql.error(f"select t2, count(*) from {self.dbname}.{self.stable} group by t2 where t2 = 1")
|
tdSql.error(f"select t2, count(*) from {self.dbname}.{self.stable} group by t2 where t2 = 1")
|
||||||
|
@ -197,6 +226,7 @@ class TDTestCase:
|
||||||
self.test_multi_group_key(self.tb_nums, nonempty_tb_num)
|
self.test_multi_group_key(self.tb_nums, nonempty_tb_num)
|
||||||
self.test_multi_agg(self.tb_nums, nonempty_tb_num)
|
self.test_multi_agg(self.tb_nums, nonempty_tb_num)
|
||||||
self.test_window(nonempty_tb_num)
|
self.test_window(nonempty_tb_num)
|
||||||
|
self.test_event_window(nonempty_tb_num)
|
||||||
|
|
||||||
## test old version before changed
|
## test old version before changed
|
||||||
# self.test_groupby('group', 0, 0)
|
# self.test_groupby('group', 0, 0)
|
||||||
|
|
|
@ -315,6 +315,39 @@ class TDTestCase:
|
||||||
|
|
||||||
tdSql.no_error('select c1 as name from (select c1, c2 as name from st) order by name')
|
tdSql.no_error('select c1 as name from (select c1, c2 as name from st) order by name')
|
||||||
|
|
||||||
|
def queryOrderBySameCol(self):
|
||||||
|
tdLog.info("query OrderBy same col ....")
|
||||||
|
tdSql.execute(f"create stable sta (ts timestamp, col1 int) tags(t1 int);")
|
||||||
|
tdSql.execute(f"create table tba1 using sta tags(1);")
|
||||||
|
tdSql.execute(f"create table tba2 using sta tags(2);")
|
||||||
|
|
||||||
|
pd = datetime.datetime.now()
|
||||||
|
ts = int(datetime.datetime.timestamp(pd)*1000*1000)
|
||||||
|
tdSql.execute(f"insert into tba1 values ({ts}, 1);")
|
||||||
|
tdSql.execute(f"insert into tba1 values ({ts+2}, 3);")
|
||||||
|
tdSql.execute(f"insert into tba1 values ({ts+3}, 4);")
|
||||||
|
tdSql.execute(f"insert into tba1 values ({ts+4}, 5);")
|
||||||
|
tdSql.execute(f"insert into tba2 values ({ts}, 2);")
|
||||||
|
tdSql.execute(f"insert into tba2 values ({ts+1}, 3);")
|
||||||
|
tdSql.execute(f"insert into tba2 values ({ts+3}, 5);")
|
||||||
|
tdSql.execute(f"insert into tba2 values ({ts+5}, 7);")
|
||||||
|
tdSql.query(f"select a.col1, b.col1 from sta a inner join sta b on a.ts = b.ts and a.ts < {ts+2} order by a.col1, b.col1;")
|
||||||
|
tdSql.checkData(0, 0, 1)
|
||||||
|
tdSql.checkData(0, 1, 1)
|
||||||
|
tdSql.checkData(1, 0, 1)
|
||||||
|
tdSql.checkData(1, 1, 2)
|
||||||
|
tdSql.query(f"select a.col1, b.col1 from sta a inner join sta b on a.ts = b.ts and a.ts < {ts+2} order by a.col1, b.col1 desc;")
|
||||||
|
tdSql.checkData(0, 0, 1)
|
||||||
|
tdSql.checkData(0, 1, 2)
|
||||||
|
tdSql.checkData(1, 0, 1)
|
||||||
|
tdSql.checkData(1, 1, 1)
|
||||||
|
|
||||||
|
tdSql.query(f"select a.col1, b.col1 from sta a inner join sta b on a.ts = b.ts and a.ts < {ts+2} order by a.col1 desc, b.col1 desc;")
|
||||||
|
tdSql.checkData(1, 0, 2)
|
||||||
|
tdSql.checkData(1, 1, 2)
|
||||||
|
tdSql.checkData(2, 0, 2)
|
||||||
|
tdSql.checkData(2, 1, 1)
|
||||||
|
|
||||||
# run
|
# run
|
||||||
def run(self):
|
def run(self):
|
||||||
# prepare env
|
# prepare env
|
||||||
|
@ -332,6 +365,8 @@ class TDTestCase:
|
||||||
# td-28332
|
# td-28332
|
||||||
self.queryOrderByAmbiguousName()
|
self.queryOrderByAmbiguousName()
|
||||||
|
|
||||||
|
self.queryOrderBySameCol()
|
||||||
|
|
||||||
# stop
|
# stop
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
from wsgiref.headers import tspecials
|
||||||
|
from util.log import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.sql import *
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdLog.debug("start to execute %s" % __file__)
|
||||||
|
tdSql.init(conn.cursor())
|
||||||
|
|
||||||
|
self.rowNum = 10
|
||||||
|
self.batchNum = 5
|
||||||
|
self.ts = 1537146000000
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
dbname = "db"
|
||||||
|
tdSql.prepare()
|
||||||
|
|
||||||
|
tdSql.execute(f'''create table sta(ts timestamp, f int, col2 bigint) tags(tg1 int, tg2 binary(20))''')
|
||||||
|
tdSql.execute(f"create table sta1 using sta tags(1, 'a')")
|
||||||
|
tdSql.execute(f"insert into sta1 values(1537146000001, 11, 110)")
|
||||||
|
tdSql.execute(f"insert into sta1 values(1537146000002, 12, 120)")
|
||||||
|
tdSql.execute(f"insert into sta1 values(1537146000003, 13, 130)")
|
||||||
|
|
||||||
|
tdSql.query("select _wstart, f+100, count(*) from db.sta partition by f+100 session(ts, 1a) order by _wstart");
|
||||||
|
tdSql.checkData(0, 1, 111.0)
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success("%s successfully executed" % __file__)
|
||||||
|
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
|
@ -72,4 +72,3 @@ class TDTestCase:
|
||||||
|
|
||||||
tdCases.addWindows(__file__, TDTestCase())
|
tdCases.addWindows(__file__, TDTestCase())
|
||||||
tdCases.addLinux(__file__, TDTestCase())
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,8 @@ class TDTestCase:
|
||||||
tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix'])
|
tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix'])
|
||||||
tdLog.info("insert data")
|
tdLog.info("insert data")
|
||||||
tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"])
|
tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"])
|
||||||
|
tdSql.execute("insert into ctb0 values(now,1,'');")
|
||||||
|
|
||||||
tdLog.info("create topics from stb with filter")
|
tdLog.info("create topics from stb with filter")
|
||||||
queryString = "select ts,c1,c2 from %s.%s" %(paraDict['dbName'], paraDict['stbName'])
|
queryString = "select ts,c1,c2 from %s.%s" %(paraDict['dbName'], paraDict['stbName'])
|
||||||
sqlString = "create topic %s as stable %s.%s" %(topicNameList[0], paraDict["dbName"],paraDict["stbName"])
|
sqlString = "create topic %s as stable %s.%s" %(topicNameList[0], paraDict["dbName"],paraDict["stbName"])
|
||||||
|
|
|
@ -0,0 +1,217 @@
|
||||||
|
|
||||||
|
import taos
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import socket
|
||||||
|
import os
|
||||||
|
import threading
|
||||||
|
import math
|
||||||
|
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.dnodes import *
|
||||||
|
from util.common import *
|
||||||
|
from util.cluster import *
|
||||||
|
sys.path.append("./7-tmq")
|
||||||
|
from tmqCommon import *
|
||||||
|
sys.path.append("./6-cluster")
|
||||||
|
from clusterCommonCreate import *
|
||||||
|
from clusterCommonCheck import clusterComCheck
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
def __init__(self):
|
||||||
|
self.vgroups = 1
|
||||||
|
self.ctbNum = 10
|
||||||
|
self.rowsPerTbl = 1000
|
||||||
|
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
tdSql.init(conn.cursor(), True)
|
||||||
|
|
||||||
|
def getDataPath(self):
|
||||||
|
selfPath = tdCom.getBuildPath()
|
||||||
|
|
||||||
|
return selfPath + '/../sim/dnode%d/data/vnode/vnode%d/wal/*';
|
||||||
|
|
||||||
|
def prepareTestEnv(self):
|
||||||
|
tdLog.printNoPrefix("======== prepare test env include database, stable, ctables, and insert data: ")
|
||||||
|
paraDict = {'dbName': 'dbt',
|
||||||
|
'dropFlag': 1,
|
||||||
|
'event': '',
|
||||||
|
'vgroups': 1,
|
||||||
|
'stbName': 'stb',
|
||||||
|
'colPrefix': 'c',
|
||||||
|
'tagPrefix': 't',
|
||||||
|
'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1},{'type': 'TIMESTAMP', 'count':1}],
|
||||||
|
'tagSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1}],
|
||||||
|
'ctbPrefix': 'ctb',
|
||||||
|
'ctbStartIdx': 0,
|
||||||
|
'ctbNum': 10,
|
||||||
|
'rowsPerTbl': 1000,
|
||||||
|
'batchNum': 10,
|
||||||
|
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
||||||
|
'pollDelay': 60,
|
||||||
|
'showMsg': 1,
|
||||||
|
'showRow': 1,
|
||||||
|
'snapshot': 0}
|
||||||
|
|
||||||
|
paraDict['vgroups'] = self.vgroups
|
||||||
|
paraDict['ctbNum'] = self.ctbNum
|
||||||
|
paraDict['rowsPerTbl'] = self.rowsPerTbl
|
||||||
|
|
||||||
|
tdCom.drop_all_db()
|
||||||
|
tmqCom.initConsumerTable()
|
||||||
|
tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], wal_retention_period=36000,vgroups=paraDict["vgroups"],replica=self.replicaVar)
|
||||||
|
tdLog.info("create stb")
|
||||||
|
tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"])
|
||||||
|
return
|
||||||
|
|
||||||
|
def restartAndRemoveWal(self, deleteWal):
|
||||||
|
tdDnodes = cluster.dnodes
|
||||||
|
tdSql.query("select * from information_schema.ins_vnodes")
|
||||||
|
for result in tdSql.queryResult:
|
||||||
|
if result[2] == 'dbt':
|
||||||
|
tdLog.debug("dnode is %d"%(result[0]))
|
||||||
|
dnodeId = result[0]
|
||||||
|
vnodeId = result[1]
|
||||||
|
|
||||||
|
tdDnodes[dnodeId - 1].stoptaosd()
|
||||||
|
time.sleep(1)
|
||||||
|
dataPath = self.getDataPath()
|
||||||
|
dataPath = dataPath%(dnodeId,vnodeId)
|
||||||
|
tdLog.debug("dataPath:%s"%dataPath)
|
||||||
|
if deleteWal:
|
||||||
|
if os.system('rm -rf ' + dataPath) != 0:
|
||||||
|
tdLog.exit("rm error")
|
||||||
|
|
||||||
|
tdDnodes[dnodeId - 1].starttaosd()
|
||||||
|
time.sleep(1)
|
||||||
|
break
|
||||||
|
tdLog.debug("restart dnode ok")
|
||||||
|
|
||||||
|
def splitVgroups(self):
|
||||||
|
tdSql.query("select * from information_schema.ins_vnodes")
|
||||||
|
vnodeId = 0
|
||||||
|
for result in tdSql.queryResult:
|
||||||
|
if result[2] == 'dbt':
|
||||||
|
vnodeId = result[1]
|
||||||
|
tdLog.debug("vnode is %d"%(vnodeId))
|
||||||
|
break
|
||||||
|
splitSql = "split vgroup %d" %(vnodeId)
|
||||||
|
tdLog.debug("splitSql:%s"%(splitSql))
|
||||||
|
tdSql.query(splitSql)
|
||||||
|
tdLog.debug("splitSql ok")
|
||||||
|
|
||||||
|
def tmqCase1(self, deleteWal=False):
|
||||||
|
tdLog.printNoPrefix("======== test case 1: ")
|
||||||
|
paraDict = {'dbName': 'dbt',
|
||||||
|
'dropFlag': 1,
|
||||||
|
'event': '',
|
||||||
|
'vgroups': 1,
|
||||||
|
'stbName': 'stb',
|
||||||
|
'colPrefix': 'c',
|
||||||
|
'tagPrefix': 't',
|
||||||
|
'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1},{'type': 'TIMESTAMP', 'count':1}],
|
||||||
|
'tagSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1}],
|
||||||
|
'ctbPrefix': 'ctb1',
|
||||||
|
'ctbStartIdx': 0,
|
||||||
|
'ctbNum': 10,
|
||||||
|
'rowsPerTbl': 1000,
|
||||||
|
'batchNum': 10,
|
||||||
|
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
||||||
|
'pollDelay': 180,
|
||||||
|
'showMsg': 1,
|
||||||
|
'showRow': 1,
|
||||||
|
'snapshot': 0}
|
||||||
|
|
||||||
|
paraDict['vgroups'] = self.vgroups
|
||||||
|
paraDict['ctbNum'] = self.ctbNum
|
||||||
|
paraDict['rowsPerTbl'] = self.rowsPerTbl
|
||||||
|
|
||||||
|
topicNameList = ['topic1']
|
||||||
|
# expectRowsList = []
|
||||||
|
tmqCom.initConsumerTable()
|
||||||
|
|
||||||
|
tdLog.info("create topics from stb with filter")
|
||||||
|
queryString = "select * from %s.%s where c2 >= 0 "%(paraDict['dbName'], paraDict['stbName'])
|
||||||
|
# sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName'])
|
||||||
|
sqlString = "create topic %s as %s" %(topicNameList[0], queryString)
|
||||||
|
tdLog.info("create topic sql: %s"%sqlString)
|
||||||
|
tdSql.execute(sqlString)
|
||||||
|
# tdSql.query(queryString)
|
||||||
|
# expectRowsList.append(tdSql.getRows())
|
||||||
|
|
||||||
|
# init consume info, and start tmq_sim, then check consume result
|
||||||
|
tdLog.info("insert consume info to consume processor")
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2
|
||||||
|
topicList = topicNameList[0]
|
||||||
|
ifcheckdata = 1
|
||||||
|
ifManualCommit = 1
|
||||||
|
keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:200, auto.offset.reset:earliest'
|
||||||
|
tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot'])
|
||||||
|
tdLog.info("wait the consume result")
|
||||||
|
|
||||||
|
tdLog.info("create ctb1")
|
||||||
|
tmqCom.create_ctable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict['ctbPrefix'],
|
||||||
|
ctbNum=paraDict["ctbNum"],ctbStartIdx=paraDict['ctbStartIdx'])
|
||||||
|
|
||||||
|
tdLog.info("create ctb2")
|
||||||
|
paraDict2 = paraDict.copy()
|
||||||
|
paraDict2['ctbPrefix'] = "ctb2"
|
||||||
|
tmqCom.create_ctable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict2['ctbPrefix'],
|
||||||
|
ctbNum=paraDict["ctbNum"],ctbStartIdx=paraDict['ctbStartIdx'])
|
||||||
|
|
||||||
|
tdLog.info("insert ctb1 data")
|
||||||
|
pInsertThread = tmqCom.asyncInsertDataByInterlace(paraDict)
|
||||||
|
|
||||||
|
tmqCom.getStartConsumeNotifyFromTmqsim()
|
||||||
|
tmqCom.getStartCommitNotifyFromTmqsim()
|
||||||
|
|
||||||
|
#restart dnode & remove wal
|
||||||
|
self.restartAndRemoveWal(deleteWal)
|
||||||
|
|
||||||
|
# split vgroup
|
||||||
|
self.splitVgroups()
|
||||||
|
|
||||||
|
|
||||||
|
tdLog.info("insert ctb2 data")
|
||||||
|
pInsertThread1 = tmqCom.asyncInsertDataByInterlace(paraDict2)
|
||||||
|
pInsertThread.join()
|
||||||
|
pInsertThread1.join()
|
||||||
|
|
||||||
|
expectRows = 1
|
||||||
|
resultList = tmqCom.selectConsumeResult(expectRows)
|
||||||
|
|
||||||
|
if expectrowcnt / 2 > resultList[0]:
|
||||||
|
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectrowcnt / 2, resultList[0]))
|
||||||
|
tdLog.exit("%d tmq consume rows error!"%consumerId)
|
||||||
|
|
||||||
|
# tmqCom.checkFileContent(consumerId, queryString)
|
||||||
|
|
||||||
|
time.sleep(2)
|
||||||
|
for i in range(len(topicNameList)):
|
||||||
|
tdSql.query("drop topic %s"%topicNameList[i])
|
||||||
|
|
||||||
|
if deleteWal == True:
|
||||||
|
clusterComCheck.check_vgroups_status(vgroup_numbers=2,db_replica=self.replicaVar,db_name="dbt",count_number=240)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case 1 end ...... ")
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.prepareTestEnv()
|
||||||
|
self.tmqCase1(False)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
event = threading.Event()
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -206,8 +206,6 @@ class TDTestCase:
|
||||||
def run(self):
|
def run(self):
|
||||||
self.prepareTestEnv()
|
self.prepareTestEnv()
|
||||||
self.tmqCase1(True)
|
self.tmqCase1(True)
|
||||||
self.prepareTestEnv()
|
|
||||||
self.tmqCase1(False)
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -0,0 +1,218 @@
|
||||||
|
|
||||||
|
import taos
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import socket
|
||||||
|
import os
|
||||||
|
import threading
|
||||||
|
import math
|
||||||
|
|
||||||
|
from util.log import *
|
||||||
|
from util.sql import *
|
||||||
|
from util.cases import *
|
||||||
|
from util.dnodes import *
|
||||||
|
from util.common import *
|
||||||
|
from util.cluster import *
|
||||||
|
sys.path.append("./7-tmq")
|
||||||
|
from tmqCommon import *
|
||||||
|
sys.path.append("./6-cluster")
|
||||||
|
from clusterCommonCreate import *
|
||||||
|
from clusterCommonCheck import clusterComCheck
|
||||||
|
|
||||||
|
class TDTestCase:
|
||||||
|
def __init__(self):
|
||||||
|
self.vgroups = 1
|
||||||
|
self.ctbNum = 10
|
||||||
|
self.rowsPerTbl = 1000
|
||||||
|
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
self.replicaVar = int(replicaVar)
|
||||||
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
tdSql.init(conn.cursor(), True)
|
||||||
|
|
||||||
|
def getDataPath(self):
|
||||||
|
selfPath = tdCom.getBuildPath()
|
||||||
|
|
||||||
|
return selfPath + '/../sim/dnode%d/data/vnode/vnode%d/wal/*';
|
||||||
|
|
||||||
|
def prepareTestEnv(self):
|
||||||
|
tdLog.printNoPrefix("======== prepare test env include database, stable, ctables, and insert data: ")
|
||||||
|
paraDict = {'dbName': 'dbt',
|
||||||
|
'dropFlag': 1,
|
||||||
|
'event': '',
|
||||||
|
'vgroups': 1,
|
||||||
|
'stbName': 'stb',
|
||||||
|
'colPrefix': 'c',
|
||||||
|
'tagPrefix': 't',
|
||||||
|
'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1},{'type': 'TIMESTAMP', 'count':1}],
|
||||||
|
'tagSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1}],
|
||||||
|
'ctbPrefix': 'ctb',
|
||||||
|
'ctbStartIdx': 0,
|
||||||
|
'ctbNum': 10,
|
||||||
|
'rowsPerTbl': 1000,
|
||||||
|
'batchNum': 10,
|
||||||
|
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
||||||
|
'pollDelay': 180,
|
||||||
|
'showMsg': 1,
|
||||||
|
'showRow': 1,
|
||||||
|
'snapshot': 0}
|
||||||
|
|
||||||
|
paraDict['vgroups'] = self.vgroups
|
||||||
|
paraDict['ctbNum'] = self.ctbNum
|
||||||
|
paraDict['rowsPerTbl'] = self.rowsPerTbl
|
||||||
|
|
||||||
|
tdCom.drop_all_db()
|
||||||
|
tmqCom.initConsumerTable()
|
||||||
|
tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], wal_retention_period=36000,vgroups=paraDict["vgroups"],replica=self.replicaVar)
|
||||||
|
tdLog.info("create stb")
|
||||||
|
tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"])
|
||||||
|
return
|
||||||
|
|
||||||
|
def restartAndRemoveWal(self, deleteWal):
|
||||||
|
tdDnodes = cluster.dnodes
|
||||||
|
tdSql.query("select * from information_schema.ins_vnodes")
|
||||||
|
for result in tdSql.queryResult:
|
||||||
|
if result[2] == 'dbt':
|
||||||
|
tdLog.debug("dnode is %d"%(result[0]))
|
||||||
|
dnodeId = result[0]
|
||||||
|
vnodeId = result[1]
|
||||||
|
|
||||||
|
tdDnodes[dnodeId - 1].stoptaosd()
|
||||||
|
time.sleep(1)
|
||||||
|
dataPath = self.getDataPath()
|
||||||
|
dataPath = dataPath%(dnodeId,vnodeId)
|
||||||
|
tdLog.debug("dataPath:%s"%dataPath)
|
||||||
|
if deleteWal:
|
||||||
|
if os.system('rm -rf ' + dataPath) != 0:
|
||||||
|
tdLog.exit("rm error")
|
||||||
|
|
||||||
|
tdDnodes[dnodeId - 1].starttaosd()
|
||||||
|
time.sleep(1)
|
||||||
|
break
|
||||||
|
tdLog.debug("restart dnode ok")
|
||||||
|
|
||||||
|
def splitVgroups(self):
|
||||||
|
tdSql.query("select * from information_schema.ins_vnodes")
|
||||||
|
vnodeId = 0
|
||||||
|
for result in tdSql.queryResult:
|
||||||
|
if result[2] == 'dbt':
|
||||||
|
vnodeId = result[1]
|
||||||
|
tdLog.debug("vnode is %d"%(vnodeId))
|
||||||
|
break
|
||||||
|
splitSql = "split vgroup %d" %(vnodeId)
|
||||||
|
tdLog.debug("splitSql:%s"%(splitSql))
|
||||||
|
tdSql.query(splitSql)
|
||||||
|
tdLog.debug("splitSql ok")
|
||||||
|
|
||||||
|
def tmqCase1(self, deleteWal=False):
|
||||||
|
tdLog.printNoPrefix("======== test case 1: ")
|
||||||
|
paraDict = {'dbName': 'dbt',
|
||||||
|
'dropFlag': 1,
|
||||||
|
'event': '',
|
||||||
|
'vgroups': 1,
|
||||||
|
'stbName': 'stb',
|
||||||
|
'colPrefix': 'c',
|
||||||
|
'tagPrefix': 't',
|
||||||
|
'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1},{'type': 'TIMESTAMP', 'count':1}],
|
||||||
|
'tagSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1}],
|
||||||
|
'ctbPrefix': 'ctb1',
|
||||||
|
'ctbStartIdx': 0,
|
||||||
|
'ctbNum': 10,
|
||||||
|
'rowsPerTbl': 1000,
|
||||||
|
'batchNum': 10,
|
||||||
|
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
||||||
|
'pollDelay': 60,
|
||||||
|
'showMsg': 1,
|
||||||
|
'showRow': 1,
|
||||||
|
'snapshot': 0}
|
||||||
|
|
||||||
|
paraDict['vgroups'] = self.vgroups
|
||||||
|
paraDict['ctbNum'] = self.ctbNum
|
||||||
|
paraDict['rowsPerTbl'] = self.rowsPerTbl
|
||||||
|
|
||||||
|
topicNameList = ['topic1']
|
||||||
|
# expectRowsList = []
|
||||||
|
tmqCom.initConsumerTable()
|
||||||
|
|
||||||
|
tdLog.info("create topics from db")
|
||||||
|
queryString = "database %s"%(paraDict['dbName'])
|
||||||
|
# sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName'])
|
||||||
|
sqlString = "create topic %s as %s" %(topicNameList[0], queryString)
|
||||||
|
tdLog.info("create topic sql: %s"%sqlString)
|
||||||
|
tdSql.execute(sqlString)
|
||||||
|
# tdSql.query(queryString)
|
||||||
|
# expectRowsList.append(tdSql.getRows())
|
||||||
|
|
||||||
|
# init consume info, and start tmq_sim, then check consume result
|
||||||
|
tdLog.info("insert consume info to consume processor")
|
||||||
|
consumerId = 0
|
||||||
|
expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2
|
||||||
|
topicList = topicNameList[0]
|
||||||
|
ifcheckdata = 1
|
||||||
|
ifManualCommit = 1
|
||||||
|
keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:200, auto.offset.reset:earliest'
|
||||||
|
tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
|
||||||
|
|
||||||
|
tdLog.info("start consume processor")
|
||||||
|
tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot'])
|
||||||
|
tdLog.info("wait the consume result")
|
||||||
|
|
||||||
|
tdLog.info("create ctb1")
|
||||||
|
tmqCom.create_ctable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict['ctbPrefix'],
|
||||||
|
ctbNum=paraDict["ctbNum"],ctbStartIdx=paraDict['ctbStartIdx'])
|
||||||
|
|
||||||
|
tdLog.info("create ctb2")
|
||||||
|
paraDict2 = paraDict.copy()
|
||||||
|
|
||||||
|
paraDict2['ctbPrefix'] = "ctb2"
|
||||||
|
tmqCom.create_ctable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict2['ctbPrefix'],
|
||||||
|
ctbNum=paraDict["ctbNum"],ctbStartIdx=paraDict['ctbStartIdx'])
|
||||||
|
|
||||||
|
tdLog.info("insert ctb1 data")
|
||||||
|
pInsertThread = tmqCom.asyncInsertDataByInterlace(paraDict)
|
||||||
|
|
||||||
|
tmqCom.getStartConsumeNotifyFromTmqsim()
|
||||||
|
tmqCom.getStartCommitNotifyFromTmqsim()
|
||||||
|
|
||||||
|
#restart dnode & remove wal
|
||||||
|
self.restartAndRemoveWal(deleteWal)
|
||||||
|
|
||||||
|
# split vgroup
|
||||||
|
self.splitVgroups()
|
||||||
|
|
||||||
|
|
||||||
|
tdLog.info("insert ctb2 data")
|
||||||
|
pInsertThread1 = tmqCom.asyncInsertDataByInterlace(paraDict2)
|
||||||
|
pInsertThread.join()
|
||||||
|
pInsertThread1.join()
|
||||||
|
|
||||||
|
expectRows = 1
|
||||||
|
resultList = tmqCom.selectConsumeResult(expectRows)
|
||||||
|
|
||||||
|
if expectrowcnt / 2 > resultList[0]:
|
||||||
|
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectrowcnt / 2, resultList[0]))
|
||||||
|
tdLog.exit("%d tmq consume rows error!"%consumerId)
|
||||||
|
|
||||||
|
# tmqCom.checkFileContent(consumerId, queryString)
|
||||||
|
|
||||||
|
time.sleep(2)
|
||||||
|
for i in range(len(topicNameList)):
|
||||||
|
tdSql.query("drop topic %s"%topicNameList[i])
|
||||||
|
|
||||||
|
if deleteWal == True:
|
||||||
|
clusterComCheck.check_vgroups_status(vgroup_numbers=2,db_replica=self.replicaVar,db_name="dbt",count_number=240)
|
||||||
|
|
||||||
|
tdLog.printNoPrefix("======== test case 1 end ...... ")
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.prepareTestEnv()
|
||||||
|
self.tmqCase1(False)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
event = threading.Event()
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -207,8 +207,6 @@ class TDTestCase:
|
||||||
def run(self):
|
def run(self):
|
||||||
self.prepareTestEnv()
|
self.prepareTestEnv()
|
||||||
self.tmqCase1(True)
|
self.tmqCase1(True)
|
||||||
self.prepareTestEnv()
|
|
||||||
self.tmqCase1(False)
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -54,7 +54,7 @@ class TDTestCase:
|
||||||
'rowsPerTbl': 1000,
|
'rowsPerTbl': 1000,
|
||||||
'batchNum': 10,
|
'batchNum': 10,
|
||||||
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
||||||
'pollDelay': 60,
|
'pollDelay': 180,
|
||||||
'showMsg': 1,
|
'showMsg': 1,
|
||||||
'showRow': 1,
|
'showRow': 1,
|
||||||
'snapshot': 0}
|
'snapshot': 0}
|
||||||
|
|
|
@ -123,7 +123,7 @@ class TDTestCase:
|
||||||
'rowsPerTbl': 1000,
|
'rowsPerTbl': 1000,
|
||||||
'batchNum': 10,
|
'batchNum': 10,
|
||||||
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
'startTs': 1640966400000, # 2022-01-01 00:00:00.000
|
||||||
'pollDelay': 120,
|
'pollDelay': 180,
|
||||||
'showMsg': 1,
|
'showMsg': 1,
|
||||||
'showRow': 1,
|
'showRow': 1,
|
||||||
'snapshot': 0}
|
'snapshot': 0}
|
||||||
|
|
Loading…
Reference in New Issue