提交 6cb9f0c5 编写于 作者: W wpan

Merge branch 'develop' into feature/TD-2581

...@@ -77,48 +77,43 @@ sudo cp -rf /usr/local/taos/connector/grafanaplugin /var/lib/grafana/plugins/tde ...@@ -77,48 +77,43 @@ sudo cp -rf /usr/local/taos/connector/grafanaplugin /var/lib/grafana/plugins/tde
## <a class="anchor" id="matlab"></a>MATLAB ## <a class="anchor" id="matlab"></a>MATLAB
MATLAB可以通过安装包内提供的JDBC Driver直接连接到TDengine获取数据到本地工作空间。 MATLAB 可以通过安装包内提供的 JDBC Driver 直接连接到 TDengine 获取数据到本地工作空间。
### MATLAB的JDBC接口适配 ### MATLAB 的 JDBC 接口适配
MATLAB的适配有下面几个步骤,下面以Windows10上适配MATLAB2017a为例: MATLAB 的适配有下面几个步骤,下面以 Windows 10 上适配 MATLAB2021a 为例:
- 将TDengine安装包内的驱动程序JDBCDriver-1.0.0-dist.jar拷贝到${matlab_root}\MATLAB\R2017a\java\jar\toolbox - 将 TDengine 客户端安装路径下的 `\TDengine\connector\jdbc的驱动程序taos-jdbcdriver-2.0.25-dist.jar` 拷贝到 `${matlab_root}\MATLAB\R2021a\java\jar\toolbox`
- 将TDengine安装包内的taos.lib文件拷贝至${matlab_ root _dir}\MATLAB\R2017a\lib\win64 - 将 TDengine 安装包内的 `taos.lib` 文件拷贝至 `${matlab_root_dir}\MATLAB\R2021\lib\win64`
- 将新添加的驱动jar包加入MATLAB的classpath。在${matlab_ root _dir}\MATLAB\R2017a\toolbox\local\classpath.txt文件中添加下面一行 - 将新添加的驱动 jar 包加入 MATLAB 的 classpath。在 `${matlab_root_dir}\MATLAB\R2021a\toolbox\local\classpath.txt` 文件中添加下面一行:
``` ```
$matlabroot/java/jar/toolbox/JDBCDriver-1.0.0-dist.jar $matlabroot/java/jar/toolbox/taos-jdbcdriver-2.0.25-dist.jar
``` ```
- 在${user_home}\AppData\Roaming\MathWorks\MATLAB\R2017a\下添加一个文件javalibrarypath.txt, 并在该文件中添加taos.dll的路径,比如您的taos.dll是在安装时拷贝到了C:\Windows\System32下,那么就应该在javalibrarypath.txt中添加如下一行: -`${user_home}\AppData\Roaming\MathWorks\MATLAB\R2021a\` 下添加一个文件 `javalibrarypath.txt`,并在该文件中添加 taos.dll 的路径,比如您的 taos.dll 是在安装时拷贝到了 `C:\Windows\System32` 下,那么就应该在 `javalibrarypath.txt` 中添加如下一行:
``` ```
C:\Windows\System32 C:\Windows\System32
``` ```
### 在MATLAB中连接TDengine获取数据 ### 在 MATLAB 中连接 TDengine 获取数据
在成功进行了上述配置后,打开MATLAB。 在成功进行了上述配置后,打开 MATLAB。
- 创建一个连接: - 创建一个连接:
```matlab ```matlab
conn = database(db, root, taosdata, com.taosdata.jdbc.TSDBDriver, jdbc:TSDB://127.0.0.1:0/) conn = database(‘test’, ‘root’, ‘taosdata’, ‘com.taosdata.jdbc.TSDBDriver’, ‘jdbc:TSDB://192.168.1.94:6030/’)
``` ```
- 执行一次查询: - 执行一次查询:
```matlab ```matlab
sql0 = [‘select * from tb’] sql0 = [‘select * from tb’]
data = select(conn, sql0); data = select(conn, sql0);
``` ```
- 插入一条记录: - 插入一条记录:
```matlab ```matlab
sql1 = [‘insert into tb values (now, 1)’] sql1 = [‘insert into tb values (now, 1)’]
exec(conn, sql1) exec(conn, sql1)
``` ```
更多例子细节请参考安装包内examples\Matlab\TDengineDemo.m文件。 更多例子细节请参考安装包内 `examples\Matlab\TDengineDemo.m` 文件。
## <a class="anchor" id="r"></a>R ## <a class="anchor" id="r"></a>R
......
...@@ -476,7 +476,14 @@ void buildFilterSetFromBinary(void **q, const char *buf, int32_t len) { ...@@ -476,7 +476,14 @@ void buildFilterSetFromBinary(void **q, const char *buf, int32_t len) {
int dummy = -1; int dummy = -1;
int32_t sz = tbufReadInt32(&br); int32_t sz = tbufReadInt32(&br);
for (int32_t i = 0; i < sz; i++) { for (int32_t i = 0; i < sz; i++) {
if (type == TSDB_DATA_TYPE_BOOL || type == TSDB_DATA_TYPE_TINYINT || type == TSDB_DATA_TYPE_SMALLINT || type == TSDB_DATA_TYPE_BIGINT || type == TSDB_DATA_TYPE_INT) { if (type == TSDB_DATA_TYPE_BOOL || IS_SIGNED_NUMERIC_TYPE(type)) {
int64_t val = tbufReadInt64(&br);
taosHashPut(pObj, (char *)&val, sizeof(val), &dummy, sizeof(dummy));
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
uint64_t val = tbufReadUint64(&br);
taosHashPut(pObj, (char *)&val, sizeof(val), &dummy, sizeof(dummy));
}
else if (type == TSDB_DATA_TYPE_TIMESTAMP) {
int64_t val = tbufReadInt64(&br); int64_t val = tbufReadInt64(&br);
taosHashPut(pObj, (char *)&val, sizeof(val), &dummy, sizeof(dummy)); taosHashPut(pObj, (char *)&val, sizeof(val), &dummy, sizeof(dummy));
} else if (type == TSDB_DATA_TYPE_DOUBLE || type == TSDB_DATA_TYPE_FLOAT) { } else if (type == TSDB_DATA_TYPE_DOUBLE || type == TSDB_DATA_TYPE_FLOAT) {
......
...@@ -632,7 +632,15 @@ int32_t tStrToInteger(const char* z, int16_t type, int32_t n, int64_t* value, bo ...@@ -632,7 +632,15 @@ int32_t tStrToInteger(const char* z, int16_t type, int32_t n, int64_t* value, bo
} }
// the string may be overflow according to errno // the string may be overflow according to errno
*value = issigned? strtoll(z, &endPtr, radix):strtoull(z, &endPtr, radix); if (!issigned) {
const char *p = z;
while(*p != 0 && *p == ' ') p++;
if (*p != 0 && *p == '-') { return -1;}
*value = strtoull(z, &endPtr, radix);
} else {
*value = strtoll(z, &endPtr, radix);
}
// not a valid integer number, return error // not a valid integer number, return error
if (endPtr - z != n || errno == ERANGE) { if (endPtr - z != n || errno == ERANGE) {
......
...@@ -77,6 +77,10 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) { ...@@ -77,6 +77,10 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) {
pVar->nLen = strRmquote(pVar->pz, token->n); pVar->nLen = strRmquote(pVar->pz, token->n);
break; break;
} }
case TSDB_DATA_TYPE_TIMESTAMP: {
pVar->i64 = taosGetTimestamp(TSDB_TIME_PRECISION_NANO);
break;
}
default: { // nType == 0 means the null value default: { // nType == 0 means the null value
type = TSDB_DATA_TYPE_NULL; type = TSDB_DATA_TYPE_NULL;
......
...@@ -5,12 +5,13 @@ ...@@ -5,12 +5,13 @@
## Install ## Install
```sh ```sh
pip install git+https://github.com/taosdata/TDengine-connector-python git clone --depth 1 https://github.com/taosdata/TDengine.git
pip install ./TDengine/src/connector/python
``` ```
## Source Code ## Source Code
[TDengine] connector for Python source code is hosted on [GitHub](https://github.com/taosdata/TDengine-connector-python). [TDengine] connector for Python source code is hosted on [GitHub](https://github.com/taosdata/TDengine/tree/develop/src/connector/python).
## License - AGPL ## License - AGPL
......
...@@ -128,29 +128,29 @@ ...@@ -128,29 +128,29 @@
#define TK_USING 110 #define TK_USING 110
#define TK_AS 111 #define TK_AS 111
#define TK_NULL 112 #define TK_NULL 112
#define TK_SELECT 113 #define TK_NOW 113
#define TK_UNION 114 #define TK_SELECT 114
#define TK_ALL 115 #define TK_UNION 115
#define TK_DISTINCT 116 #define TK_ALL 116
#define TK_FROM 117 #define TK_DISTINCT 117
#define TK_VARIABLE 118 #define TK_FROM 118
#define TK_INTERVAL 119 #define TK_VARIABLE 119
#define TK_SESSION 120 #define TK_INTERVAL 120
#define TK_STATE_WINDOW 121 #define TK_SESSION 121
#define TK_FILL 122 #define TK_STATE_WINDOW 122
#define TK_SLIDING 123 #define TK_FILL 123
#define TK_ORDER 124 #define TK_SLIDING 124
#define TK_BY 125 #define TK_ORDER 125
#define TK_ASC 126 #define TK_BY 126
#define TK_DESC 127 #define TK_ASC 127
#define TK_GROUP 128 #define TK_DESC 128
#define TK_HAVING 129 #define TK_GROUP 129
#define TK_LIMIT 130 #define TK_HAVING 130
#define TK_OFFSET 131 #define TK_LIMIT 131
#define TK_SLIMIT 132 #define TK_OFFSET 132
#define TK_SOFFSET 133 #define TK_SLIMIT 133
#define TK_WHERE 134 #define TK_SOFFSET 134
#define TK_NOW 135 #define TK_WHERE 135
#define TK_RESET 136 #define TK_RESET 136
#define TK_QUERY 137 #define TK_QUERY 137
#define TK_SYNCDB 138 #define TK_SYNCDB 138
......
...@@ -437,6 +437,7 @@ tagitem(A) ::= FLOAT(X). { toTSDBType(X.type); tVariantCreate(&A, &X); } ...@@ -437,6 +437,7 @@ tagitem(A) ::= FLOAT(X). { toTSDBType(X.type); tVariantCreate(&A, &X); }
tagitem(A) ::= STRING(X). { toTSDBType(X.type); tVariantCreate(&A, &X); } tagitem(A) ::= STRING(X). { toTSDBType(X.type); tVariantCreate(&A, &X); }
tagitem(A) ::= BOOL(X). { toTSDBType(X.type); tVariantCreate(&A, &X); } tagitem(A) ::= BOOL(X). { toTSDBType(X.type); tVariantCreate(&A, &X); }
tagitem(A) ::= NULL(X). { X.type = 0; tVariantCreate(&A, &X); } tagitem(A) ::= NULL(X). { X.type = 0; tVariantCreate(&A, &X); }
tagitem(A) ::= NOW(X). { X.type = TSDB_DATA_TYPE_TIMESTAMP; tVariantCreate(&A, &X);}
tagitem(A) ::= MINUS(X) INTEGER(Y).{ tagitem(A) ::= MINUS(X) INTEGER(Y).{
X.n += Y.n; X.n += Y.n;
......
...@@ -2943,7 +2943,9 @@ void setTagValue(SOperatorInfo* pOperatorInfo, void *pTable, SQLFunctionCtx* pCt ...@@ -2943,7 +2943,9 @@ void setTagValue(SOperatorInfo* pOperatorInfo, void *pTable, SQLFunctionCtx* pCt
doSetTagValueInParam(pTable, pLocalExprInfo->base.colInfo.colId, &pCtx[idx].tag, pLocalExprInfo->base.resType, doSetTagValueInParam(pTable, pLocalExprInfo->base.colInfo.colId, &pCtx[idx].tag, pLocalExprInfo->base.resType,
pLocalExprInfo->base.resBytes); pLocalExprInfo->base.resBytes);
if (IS_NUMERIC_TYPE(pLocalExprInfo->base.resType) || pLocalExprInfo->base.resType == TSDB_DATA_TYPE_BOOL) { if (IS_NUMERIC_TYPE(pLocalExprInfo->base.resType)
|| pLocalExprInfo->base.resType == TSDB_DATA_TYPE_BOOL
|| pLocalExprInfo->base.resType == TSDB_DATA_TYPE_TIMESTAMP) {
memcpy(pRuntimeEnv->tagVal + offset, &pCtx[idx].tag.i64, pLocalExprInfo->base.resBytes); memcpy(pRuntimeEnv->tagVal + offset, &pCtx[idx].tag.i64, pLocalExprInfo->base.resBytes);
} else { } else {
memcpy(pRuntimeEnv->tagVal + offset, pCtx[idx].tag.pz, pCtx[idx].tag.nLen); memcpy(pRuntimeEnv->tagVal + offset, pCtx[idx].tag.pz, pCtx[idx].tag.nLen);
......
...@@ -254,15 +254,23 @@ bool notNullOperator(SColumnFilterElem *pFilter, const char* minval, const char* ...@@ -254,15 +254,23 @@ bool notNullOperator(SColumnFilterElem *pFilter, const char* minval, const char*
return true; return true;
} }
bool inOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type) { bool inOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type) {
if (type == TSDB_DATA_TYPE_BOOL || type == TSDB_DATA_TYPE_TINYINT || type == TSDB_DATA_TYPE_SMALLINT || type == TSDB_DATA_TYPE_BIGINT || type == TSDB_DATA_TYPE_INT) { if (type == TSDB_DATA_TYPE_BOOL || IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_TIMESTAMP) {
int64_t minv = -1, maxv = -1; int64_t minv = -1, maxv = -1;
GET_TYPED_DATA(minv, int64_t, type, minval); GET_TYPED_DATA(minv, int64_t, type, minval);
GET_TYPED_DATA(maxv, int64_t, type, maxval); GET_TYPED_DATA(maxv, int64_t, type, maxval);
if (minv == maxv) { if (minv == maxv) {
return NULL != taosHashGet((SHashObj *)pFilter->q, (char *)&minv, sizeof(minv)); return NULL != taosHashGet((SHashObj *)pFilter->q, (char *)&minv, sizeof(minv));
} }
return true; return false;
} else if (type == TSDB_DATA_TYPE_DOUBLE || type == TSDB_DATA_TYPE_FLOAT) { } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
uint64_t minv = 0, maxv = 0;
GET_TYPED_DATA(minv, uint64_t, type, minval);
GET_TYPED_DATA(maxv, uint64_t, type, maxval);
if (minv == maxv) {
return NULL != taosHashGet((SHashObj *)pFilter->q, (char *)&minv, sizeof(minv));
}
return false;
}else if (type == TSDB_DATA_TYPE_DOUBLE || type == TSDB_DATA_TYPE_FLOAT) {
double v; double v;
GET_TYPED_DATA(v, double, type, minval); GET_TYPED_DATA(v, double, type, minval);
return NULL != taosHashGet((SHashObj *)pFilter->q, (char *)&v, sizeof(v)); return NULL != taosHashGet((SHashObj *)pFilter->q, (char *)&v, sizeof(v));
......
此差异已折叠。
...@@ -3355,11 +3355,16 @@ static bool tableFilterFp(const void* pNode, void* param) { ...@@ -3355,11 +3355,16 @@ static bool tableFilterFp(const void* pNode, void* param) {
} }
} else if (pInfo->optr == TSDB_RELATION_IN) { } else if (pInfo->optr == TSDB_RELATION_IN) {
int type = pInfo->sch.type; int type = pInfo->sch.type;
if (type == TSDB_DATA_TYPE_BOOL || type == TSDB_DATA_TYPE_TINYINT || type == TSDB_DATA_TYPE_SMALLINT || type == TSDB_DATA_TYPE_BIGINT || type == TSDB_DATA_TYPE_INT) { if (type == TSDB_DATA_TYPE_BOOL || IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_TIMESTAMP) {
int64_t v; int64_t v;
GET_TYPED_DATA(v, int64_t, pInfo->sch.type, val); GET_TYPED_DATA(v, int64_t, pInfo->sch.type, val);
return NULL != taosHashGet((SHashObj *)pInfo->q, (char *)&v, sizeof(v)); return NULL != taosHashGet((SHashObj *)pInfo->q, (char *)&v, sizeof(v));
} else if (type == TSDB_DATA_TYPE_DOUBLE || type == TSDB_DATA_TYPE_DOUBLE) { } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
uint64_t v;
GET_TYPED_DATA(v, uint64_t, pInfo->sch.type, val);
return NULL != taosHashGet((SHashObj *)pInfo->q, (char *)&v, sizeof(v));
}
else if (type == TSDB_DATA_TYPE_DOUBLE || type == TSDB_DATA_TYPE_DOUBLE) {
double v; double v;
GET_TYPED_DATA(v, double, pInfo->sch.type, val); GET_TYPED_DATA(v, double, pInfo->sch.type, val);
return NULL != taosHashGet((SHashObj *)pInfo->q, (char *)&v, sizeof(v)); return NULL != taosHashGet((SHashObj *)pInfo->q, (char *)&v, sizeof(v));
......
...@@ -9,11 +9,15 @@ ...@@ -9,11 +9,15 @@
<version>SNAPSHOT</version> <version>SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties>
<project.assembly.dir>src/main/resources/assembly</project.assembly.dir>
</properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.taosdata.jdbc</groupId> <groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId> <artifactId>taos-jdbcdriver</artifactId>
<version>2.0.22</version> <version>2.0.30</version>
</dependency> </dependency>
</dependencies> </dependencies>
...@@ -22,20 +26,60 @@ ...@@ -22,20 +26,60 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version> <version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.taosdata.example.JDBCDemo</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions> <executions>
<!-- jdbcDemo -->
<execution>
<id>JdbcDemo</id>
<configuration>
<finalName>JdbcDemo</finalName>
<archive>
<manifest>
<mainClass>com.taosdata.example.JdbcDemo</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
<execution>
<id>JdbcRestfulDemo</id>
<configuration>
<finalName>JdbcRestfulDemo</finalName>
<archive>
<manifest>
<mainClass>com.taosdata.example.JdbcRestfulDemo</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
<execution> <execution>
<id>make-assembly</id> <id>SubscribeDemo</id>
<configuration>
<finalName>SubscribeDemo</finalName>
<archive>
<manifest>
<mainClass>com.taosdata.example.SubscribeDemo</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>single</goal> <goal>single</goal>
......
...@@ -11,12 +11,12 @@ Download the tdengine package on our website: ``https://www.taosdata.com/cn/all- ...@@ -11,12 +11,12 @@ Download the tdengine package on our website: ``https://www.taosdata.com/cn/all-
## Run jdbcDemo using mvn plugin ## Run jdbcDemo using mvn plugin
run command: run command:
``` ```
mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JDBCDemo" mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo"
``` ```
and run with your customed args and run with your customed args
``` ```
mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JDBCDemo" -Dexec.args="-host [HOSTNAME]" mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo" -Dexec.args="-host [HOSTNAME]"
``` ```
## Compile the Demo Code and Run It ## Compile the Demo Code and Run It
......
...@@ -3,7 +3,7 @@ package com.taosdata.example; ...@@ -3,7 +3,7 @@ package com.taosdata.example;
import java.sql.*; import java.sql.*;
import java.util.Properties; import java.util.Properties;
public class JDBCDemo { public class JdbcDemo {
private static String host; private static String host;
private static final String dbName = "test"; private static final String dbName = "test";
private static final String tbName = "weather"; private static final String tbName = "weather";
...@@ -17,7 +17,7 @@ public class JDBCDemo { ...@@ -17,7 +17,7 @@ public class JDBCDemo {
if (host == null) { if (host == null) {
printHelp(); printHelp();
} }
JDBCDemo demo = new JDBCDemo(); JdbcDemo demo = new JdbcDemo();
demo.init(); demo.init();
demo.createDatabase(); demo.createDatabase();
demo.useDatabase(); demo.useDatabase();
......
...@@ -4,7 +4,7 @@ import java.sql.*; ...@@ -4,7 +4,7 @@ import java.sql.*;
import java.util.Properties; import java.util.Properties;
public class JdbcRestfulDemo { public class JdbcRestfulDemo {
private static final String host = "master"; private static final String host = "127.0.0.1";
public static void main(String[] args) { public static void main(String[] args) {
try { try {
......
...@@ -73,6 +73,7 @@ python3 ./test.py -f tag_lite/int.py ...@@ -73,6 +73,7 @@ python3 ./test.py -f tag_lite/int.py
python3 ./test.py -f tag_lite/set.py python3 ./test.py -f tag_lite/set.py
python3 ./test.py -f tag_lite/smallint.py python3 ./test.py -f tag_lite/smallint.py
python3 ./test.py -f tag_lite/tinyint.py python3 ./test.py -f tag_lite/tinyint.py
python3 ./test.py -f tag_lite/timestamp.py
#python3 ./test.py -f dbmgmt/database-name-boundary.py #python3 ./test.py -f dbmgmt/database-name-boundary.py
python3 test.py -f dbmgmt/nanoSecondCheck.py python3 test.py -f dbmgmt/nanoSecondCheck.py
......
...@@ -16,7 +16,7 @@ import taos ...@@ -16,7 +16,7 @@ import taos
from util.log import * from util.log import *
from util.cases import * from util.cases import *
from util.sql import * from util.sql import *
import numpy as np #import numpy as np
class TDTestCase: class TDTestCase:
......
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
def run(self):
tdSql.prepare()
tdLog.info('======================== dnode1 start')
tbPrefix = "ta_fl_tb"
mtPrefix = "ta_fl_mt"
tbNum = 10
rowNum = 20
totalNum = 200
tdLog.info('=============== step1')
i = 0
mt = "%s%d" % (mtPrefix, i)
tdSql.execute(
'create table %s (ts timestamp, tbcol int) TAGS(tgcol float, tgTs timestamp, tgcol2 int)' %(mt))
i = 0
ts = 1605045600000
tsStr = "2020-11-11 06:00:00"
while (i < 5):
tb = "%s%d" % (tbPrefix, i)
tdLog.info('create table %s using %s tags(%d, %d, %d)' % (tb, mt, i, ts + i, i))
tdSql.execute('create table %s using %s tags(%d, %d, %d)' % (tb, mt, i, ts + i, i))
x = 0
while (x < rowNum):
ms = x * 60000
#tdLog.info(
# "insert into %s values (%d, %d)" %
# (tb, 1605045600000 + ms, x))
tdSql.execute(
"insert into %s values (%d, %d)" %
(tb, 1605045600000 + ms, x))
x = x + 1
i = i + 1
tdLog.info('=============== step2')
tdSql.query('select * from %s' % (mt))
tdSql.checkRows(5 * rowNum)
tdSql.query('select * from %s where tgTs = %ld and tgcol2 = 0' % (mt, ts))
tdSql.checkRows(rowNum)
tdSql.query('select * from %s where tgTs = \"%s\" and tgcol2 = 0' % (mt, tsStr))
tdSql.checkRows(rowNum)
tdLog.info('=============== step3')
i = 0
while (i < 5):
tb = "%s%d" % (tbPrefix, i + 100)
tdLog.info('create table %s using %s tags(%d, \"%s\", %d)' % (tb, mt, i + 100, tsStr, i + 100))
tdSql.execute('create table %s using %s tags(%d, \"%s\", %d)' % (tb, mt, i + 100, tsStr, i + 100))
x = 0
while (x < rowNum):
ms = x * 60000
#tdLog.info(
# "insert into %s values (%d, %d)" %
# (tb, 1605045600000 + ms, x))
tdSql.execute(
"insert into %s values (%d, %d)" %
(tb, 1605045600000 + ms, x))
x = x + 1
i = i + 1
tdSql.query('select * from %s where tgTs = %ld and tgcol2 = 100' % (mt, ts))
tdSql.checkRows(rowNum)
tdSql.query('select * from %s where tgTs = \"%s\" and tgcol2 = 100' % (mt, tsStr))
tdSql.checkRows(rowNum)
tdLog.info('=============== step4')
i = 0
tb = "%s%d"%(tbPrefix, i + 1000)
tdSql.execute('insert into %s using %s tags(%d, \"%s\", %d) values(now, 10)' % (tb, mt, i + 100, tsStr, i + 1000))
tdSql.execute('insert into %s using %s tags(%d, \"%s\", %d) values(now+2s, 10)' % (tb, mt, i + 100, tsStr, i + 1000))
tdSql.execute('insert into %s using %s tags(%d, \"%s\", %d) values(now+3s, 10)' % (tb, mt, i + 100, tsStr, i + 1000))
tdSql.query('select * from %s where tgTs = \"%s\" and tgcol2 = 1000' % (mt, tsStr))
tdSql.checkRows(3)
i = 0
tb = "%s%d"%(tbPrefix, i + 10000)
tdSql.execute('create table %s using %s tags(%d, now, %d)' % (tb, mt, i + 10000,i + 10000))
tdSql.checkRows(3)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
...@@ -159,4 +159,4 @@ if $rows != 0 then ...@@ -159,4 +159,4 @@ if $rows != 0 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print ======================== dnode1 start
$dbPrefix = db
$tbPrefix = tb
$mtPrefix = st
$tbNum = 10
$rowNum = 20
$totalNum = 200
print =============== step1
$i = 0
$db = $dbPrefix . $i
$mt = $mtPrefix . $i
sql create database $db
sql use $db
sql create table $mt (ts timestamp, tbcol bigint unsigned) TAGS(tgcol bigint unsigned)
$i = 0
while $i < 5
$tb = $tbPrefix . $i
sql create table $tb using $mt tags( 0 )
sql create table $tb using $mt tags( -111 )
$x = 0
while $x < $rowNum
$ms = $x . m
sql insert into $tb values (now + $ms , 0 )
$x = $x + 1
sql_error insert into $tb values (now + $ms , -10)
sql_error insert into $tb values (now + $ms , -1000)
sql_error insert into $tb values (now + $ms , -10000000)
endw
$i = $i + 1
endw
while $i < 10
$tb = $tbPrefix . $i
sql create table $tb using $mt tags( 1 )
$x = 0
while $x < $rowNum
$ms = $x . m
sql insert into $tb values (now + $ms , 1 )
$x = $x + 1
endw
$i = $i + 1
endw
print =============== step2
sql select * from $mt where tbcol = 0
if $rows != 100 then
return -1
endi
sql select * from $mt where tbcol <> 0
if $rows != 100 then
return -1
endi
sql select * from $mt where tbcol = 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tbcol <> 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tbcol = 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tbcol <> 1
if $rows != 100 then
return -1
endi
sql select * from $mt where tbcol = 0
if $rows != 100 then
return -1
endi
sql select * from $mt where tbcol <> 0
if $rows != 100 then
return -1
endi
print =============== step3
sql select * from $mt where ts > now + 4m and tbcol = 1
if $rows != 75 then
return -1
endi
sql select * from $mt where ts > now + 4m and tbcol <> 1
if $rows != 75 then
return -1
endi
sql select * from $mt where ts < now + 4m and tbcol = 0
if $rows != 25 then
return -1
endi
sql select * from $mt where ts < now + 4m and tbcol <> 0
if $rows != 25 then
return -1
endi
sql select * from $mt where ts <= now + 4m and tbcol = 0
if $rows != 25 then
return -1
endi
sql select * from $mt where ts <= now + 4m and tbcol <> 0
if $rows != 25 then
return -1
endi
sql select * from $mt where ts > now + 4m and ts < now + 5m and tbcol <> 0
if $rows != 5 then
return -1
endi
sql select * from $mt where ts > now + 4m and tbcol <> 0 and ts < now + 5m
if $rows != 5 then
return -1
endi
print =============== step4
sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt
print $data00 $data01 $data02 $data03 $data04 $data05 $data06
if $data00 != 200 then
return -1
endi
print =============== step5
sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1
print $data00 $data01 $data02 $data03 $data04 $data05 $data06
if $data00 != 100 then
return -1
endi
print =============== step6
sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol
print $data00 $data01 $data02 $data03 $data04 $data05 $data06
print $data10 $data11 $data12 $data13 $data14 $data15 $data16
if $data00 != 100 then
print expect 100, actual $data00
return -1
endi
print =============== step7
sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = 1 group by tgcol
print $data00 $data01 $data02 $data03 $data04 $data05 $data06
if $data00 != 25 then
return -1
endi
print =============== step8
sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 interval(1d) group by tgcol order by tgcol desc
print $data00 $data01 $data02 $data03 $data04 $data05 $data06
if $data01 != 100 then
return -1
endi
print =============== clear
sql drop database $db
sql show databases
if $rows != 0 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
...@@ -99,7 +99,7 @@ $i_binary2 = varchar(20) # illegal string ...@@ -99,7 +99,7 @@ $i_binary2 = varchar(20) # illegal string
$i_bool = boolean $i_bool = boolean
$nchar = nchar # nchar with unspecified length $nchar = nchar # nchar with unspecified length
print ========== create_mt.sim case4: illegal data types in tags test print ========== create_mt.sim case4: illegal data types in tags test
sql_error create table $mt (ts timestamp, col int) tags (tag1 timestamp ) ##sql_error create table $mt (ts timestamp, col int) tags (tag1 timestamp )
sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_ts ) sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_ts )
sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_binary ) sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_binary )
sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_bigint ) sql_error create table $mt (ts timestamp, col int) tags (tag1 $i_bigint )
...@@ -253,4 +253,4 @@ if $rows != 0 then ...@@ -253,4 +253,4 @@ if $rows != 0 then
return -1 return -1
endi endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
...@@ -155,8 +155,8 @@ sql_error select last(*) from wh_mt1_tb1 where c6 in ('1') ...@@ -155,8 +155,8 @@ sql_error select last(*) from wh_mt1_tb1 where c6 in ('1')
#sql_error select last(*) from wh_mt1_tb1 where c7 in ('binary') #sql_error select last(*) from wh_mt1_tb1 where c7 in ('binary')
#sql_error select last(*) from wh_mt1 where c8 in ('nchar') #sql_error select last(*) from wh_mt1 where c8 in ('nchar')
#sql_error select last(*) from wh_mt1_tb1 where c9 in (true, false) #sql_error select last(*) from wh_mt1_tb1 where c9 in (true, false)
sql_error select last(*) from wh_mt1 where c10 in ('2019-01-01 00:00:00.000') #sql_error select last(*) from wh_mt1 where c10 in ('2019-01-01 00:00:00.000')
sql_error select last(*) from wh_mt1_tb1 where c10 in ('2019-01-01 00:00:00.000') #sql_error select last(*) from wh_mt1_tb1 where c10 in ('2019-01-01 00:00:00.000')
sql select last(*) from wh_mt1 where c1 = 1 sql select last(*) from wh_mt1 where c1 = 1
if $rows != 1 then if $rows != 1 then
return -1 return -1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册