@@ -202,6 +202,10 @@ The configuration parameters in the URL are as follows.
...
@@ -202,6 +202,10 @@ The configuration parameters in the URL are as follows.
- batchfetch: true: pull the result set in batch when executing the query; false: pull the result set row by row. The default value is false. batchfetch uses HTTP for data transfer. The JDBC REST connection supports bulk data pulling function in taos-jdbcdriver-2.0.38 and TDengine 2.4.0.12 and later versions. taos-jdbcdriver and TDengine transfer data via WebSocket connection. Compared with HTTP, WebSocket enables JDBC REST connection to support large data volume querying and improve query performance.
- batchfetch: true: pull the result set in batch when executing the query; false: pull the result set row by row. The default value is false. batchfetch uses HTTP for data transfer. The JDBC REST connection supports bulk data pulling function in taos-jdbcdriver-2.0.38 and TDengine 2.4.0.12 and later versions. taos-jdbcdriver and TDengine transfer data via WebSocket connection. Compared with HTTP, WebSocket enables JDBC REST connection to support large data volume querying and improve query performance.
- charset: specify the charset to parse the string, this parameter is valid only when set batchfetch to true.
- charset: specify the charset to parse the string, this parameter is valid only when set batchfetch to true.
- batchErrorIgnore: true: when executing executeBatch of Statement, if one SQL execution fails in the middle, continue to execute the following SQL. false: no longer execute any statement after the failed SQL. The default value is: false.
- batchErrorIgnore: true: when executing executeBatch of Statement, if one SQL execution fails in the middle, continue to execute the following SQL. false: no longer execute any statement after the failed SQL. The default value is: false.
- httpConnectTimeout: REST connection timeout in milliseconds, the default value is 5000 ms.
- httpSocketTimeout: socket timeout in milliseconds, the default value is 5000 ms. It only takes effect when batchfetch is false.
- messageWaitTimeout: message transmission timeout in milliseconds, the default value is 3000 ms. It only takes effect when batchfetch is true.
- useSSL: connecting Securely Using SSL. true: using SSL conneciton, false: not using SSL connection.
**Note**: Some configuration items (e.g., locale, timezone) do not work in the REST connection.
**Note**: Some configuration items (e.g., locale, timezone) do not work in the REST connection.
...
@@ -257,14 +261,18 @@ In the above example, a connection is established to `taosdemo.com`, port is 603
...
@@ -257,14 +261,18 @@ In the above example, a connection is established to `taosdemo.com`, port is 603
The configuration parameters in properties are as follows.
The configuration parameters in properties are as follows.
- TSDBDriver.PROPERTY_KEY_USER: Login TDengine user name, default value 'root'.
- TSDBDriver.PROPERTY_KEY_USER: login TDengine user name, default value 'root'.
- TSDBDriver.PROPERTY_KEY_PASSWORD: user login password, default value 'taosdata'.
- TSDBDriver.PROPERTY_KEY_PASSWORD: user login password, default value 'taosdata'.
- TSDBDriver.PROPERTY_KEY_BATCH_LOAD: true: pull the result set in batch when executing query; false: pull the result set row by row. The default value is: false.
- TSDBDriver.PROPERTY_KEY_BATCH_LOAD: true: pull the result set in batch when executing query; false: pull the result set row by row. The default value is: false.
- TSDBDriver.PROPERTY_KEY_BATCH_ERROR_IGNORE: true: when executing executeBatch of Statement, if there is a SQL execution failure in the middle, continue to execute the following sq. false: no longer execute any statement after the failed SQL. The default value is: false.
- TSDBDriver.PROPERTY_KEY_BATCH_ERROR_IGNORE: true: when executing executeBatch of Statement, if there is a SQL execution failure in the middle, continue to execute the following sq. false: no longer execute any statement after the failed SQL. The default value is: false.
- TSDBDriver.PROPERTY_KEY_CONFIG_DIR: Only works when using JDBC native connection. Client configuration file directory path, default value `/etc/taos` on Linux OS, default value `C:/TDengine/cfg` on Windows OS.
- TSDBDriver.PROPERTY_KEY_CONFIG_DIR: only works when using JDBC native connection. Client configuration file directory path, default value `/etc/taos` on Linux OS, default value `C:/TDengine/cfg` on Windows OS.
- TSDBDriver.PROPERTY_KEY_CHARSET: In the character set used by the client, the default value is the system character set.
- TSDBDriver.PROPERTY_KEY_CHARSET: In the character set used by the client, the default value is the system character set.
- TSDBDriver.PROPERTY_KEY_LOCALE: this only takes effect when using JDBC native connection. Client language environment, the default value is system current locale.
- TSDBDriver.PROPERTY_KEY_LOCALE: this only takes effect when using JDBC native connection. Client language environment, the default value is system current locale.
- TSDBDriver.PROPERTY_KEY_TIME_ZONE: only takes effect when using JDBC native connection. In the time zone used by the client, the default value is the system's current time zone.
- TSDBDriver.PROPERTY_KEY_TIME_ZONE: only takes effect when using JDBC native connection. In the time zone used by the client, the default value is the system's current time zone.
- TSDBDriver.HTTP_CONNECT_TIMEOUT: REST connection timeout in milliseconds, the default value is 5000 ms. It only takes effect when using JDBC REST connection.
- TSDBDriver.HTTP_SOCKET_TIMEOUT: socket timeout in milliseconds, the default value is 5000 ms. It only takes effect when using JDBC REST connection and batchfetch is false.
- TSDBDriver.PROPERTY_KEY_MESSAGE_WAIT_TIMEOUT: message transmission timeout in milliseconds, the default value is 3000 ms. It only takes effect when using JDBC REST connection and batchfetch is true.
- TSDBDriver.PROPERTY_KEY_USE_SSL: connecting Securely Using SSL. true: using SSL conneciton, false: not using SSL connection. It only takes effect when using using JDBC REST connection.
For JDBC native connections, you can specify other parameters, such as log level, SQL length, etc., by specifying URL and Properties. For more detailed configuration, please refer to [Client Configuration](/reference/config/#Client-Only).
For JDBC native connections, you can specify other parameters, such as log level, SQL length, etc., by specifying URL and Properties. For more detailed configuration, please refer to [Client Configuration](/reference/config/#Client-Only).
### Priority of configuration parameters
### Priority of configuration parameters
...
@@ -812,11 +820,12 @@ Please refer to: [JDBC example](https://github.com/taosdata/TDengine/tree/develo
...
@@ -812,11 +820,12 @@ Please refer to: [JDBC example](https://github.com/taosdata/TDengine/tree/develo
origin_sql="select {} from {} order by tbname".format(colname,'test.'+tbname)
origin_sql="select {} from {} order by tbname".format(colname,'test.'+tbname)
ifcoltype[1]insupport_types:
ifcoltype[1]insupport_types:
self.check_result_auto(origin_sql,abs_sql)
self.check_result_auto(origin_sql,abs_sql)
defprepare_datas(self,cache_value):
defprepare_datas(self,cache_value):
tdSql.execute("drop database if exists db ")
tdSql.execute("drop database if exists db ")
create_db_sql=f"create database if not exists db keep 3650 duration 1000 cachemodel {cache_value}"
create_db_sql=f"create database if not exists db keep 3650 duration 1000 cachemodel {cache_value}"
...
@@ -220,22 +220,22 @@ class TDTestCase:
...
@@ -220,22 +220,22 @@ class TDTestCase:
deftest_errors(self):
deftest_errors(self):
tdSql.execute("use testdb")
tdSql.execute("use testdb")
# bug need fix
# bug need fix
tdSql.error("select last_row(c1 ,NULL) from testdb.t1")
tdSql.query("select last_row(c1 ,NULL) from testdb.t1")
error_sql_lists=[
error_sql_lists=[
"select last_row from testdb.t1",
"select last_row from testdb.t1",
"select last_row(-+--+c1) from testdb.t1",
"select last_row(-+--+c1) from testdb.t1",
"select last_row(123--123)==1 from testdb.t1",
"select last_row(123--123)==1 from testdb.t1",
"select last_row(c1) as 'd1' from testdb.t1",
"select last_row(c1) as 'd1' from testdb.t1",
"select last_row(c1 ,NULL) from testdb.t1",
#"select last_row(c1 ,NULL) from testdb.t1",
"select last_row(,) from testdb.t1;",
"select last_row(,) from testdb.t1;",
"select last_row(abs(c1) ab from testdb.t1)",
"select last_row(abs(c1) ab from testdb.t1)",
"select last_row(c1) as int from testdb.t1",
"select last_row(c1) as int from testdb.t1",
"select last_row from testdb.stb1",
"select last_row from testdb.stb1",
"select last_row(123--123)==1 from testdb.stb1",
"select last_row(123--123)==1 from testdb.stb1",
"select last_row(c1) as 'd1' from testdb.stb1",
"select last_row(c1) as 'd1' from testdb.stb1",
"select last_row(c1 ,NULL) from testdb.stb1",
#"select last_row(c1 ,NULL) from testdb.stb1",
"select last_row(,) from testdb.stb1;",
"select last_row(,) from testdb.stb1;",
"select last_row(abs(c1) ab from testdb.stb1)",
"select last_row(abs(c1) ab from testdb.stb1)",
"select last_row(c1) as int from testdb.stb1"
"select last_row(c1) as int from testdb.stb1"
...
@@ -246,7 +246,7 @@ class TDTestCase:
...
@@ -246,7 +246,7 @@ class TDTestCase:
defsupport_types(self):
defsupport_types(self):
tdSql.execute("use testdb")
tdSql.execute("use testdb")
tbnames=["stb1","t1","ct1","ct2"]
tbnames=["stb1","t1","ct1","ct2"]
fortbnameintbnames:
fortbnameintbnames:
tdSql.query("desc {}".format(tbname))
tdSql.query("desc {}".format(tbname))
coltypes=tdSql.queryResult
coltypes=tdSql.queryResult
...
@@ -256,7 +256,7 @@ class TDTestCase:
...
@@ -256,7 +256,7 @@ class TDTestCase:
ifcol_note!="TAG":
ifcol_note!="TAG":
abs_sql="select last_row({}) from {}".format(colname,"testdb."+tbname)
abs_sql="select last_row({}) from {}".format(colname,"testdb."+tbname)
tdSql.query(abs_sql)
tdSql.query(abs_sql)
defbasic_abs_function(self):
defbasic_abs_function(self):
...
@@ -283,7 +283,7 @@ class TDTestCase:
...
@@ -283,7 +283,7 @@ class TDTestCase:
# used for regular table
# used for regular table
# bug need fix
# bug need fix
tdSql.query("select last_row(c1) from testdb.t1")
tdSql.query("select last_row(c1) from testdb.t1")
tdSql.checkData(0,0,None)
tdSql.checkData(0,0,None)
tdSql.query("select last_row(c1) from testdb.ct4")
tdSql.query("select last_row(c1) from testdb.ct4")
...
@@ -291,21 +291,21 @@ class TDTestCase:
...
@@ -291,21 +291,21 @@ class TDTestCase:
tdSql.query("select last_row(c1) from testdb.stb1")
tdSql.query("select last_row(c1) from testdb.stb1")
tdSql.checkData(0,0,None)
tdSql.checkData(0,0,None)
# # bug need fix
# # bug need fix
tdSql.query("select last_row(c1), c2, c3 , c4, c5 from testdb.t1")
tdSql.query("select last_row(c1), c2, c3 , c4, c5 from testdb.t1")
tdSql.checkData(0,0,None)
tdSql.checkData(0,0,None)
tdSql.checkData(0,1,None)
tdSql.checkData(0,1,None)
tdSql.checkData(0,2,None)
tdSql.checkData(0,2,None)
# # bug need fix
# # bug need fix
tdSql.query("select last_row(c1), c2, c3 , c4, c5 from testdb.ct1")
tdSql.query("select last_row(c1), c2, c3 , c4, c5 from testdb.ct1")
tdSql.checkData(0,0,9)
tdSql.checkData(0,0,9)
tdSql.checkData(0,1,-99999)
tdSql.checkData(0,1,-99999)
tdSql.checkData(0,2,-999)
tdSql.checkData(0,2,-999)
tdSql.checkData(0,3,None)
tdSql.checkData(0,3,None)
tdSql.checkData(0,4,-9.99000)
tdSql.checkData(0,4,-9.99000)
# bug need fix
# bug need fix
tdSql.query("select last_row(c1), c2, c3 , c4, c5 from testdb.stb1 where tbname='ct1'")
tdSql.query("select last_row(c1), c2, c3 , c4, c5 from testdb.stb1 where tbname='ct1'")
tdSql.checkData(0,0,9)
tdSql.checkData(0,0,9)
tdSql.checkData(0,1,-99999)
tdSql.checkData(0,1,-99999)
...
@@ -313,14 +313,14 @@ class TDTestCase:
...
@@ -313,14 +313,14 @@ class TDTestCase:
tdSql.checkData(0,3,None)
tdSql.checkData(0,3,None)
tdSql.checkData(0,4,-9.99000)
tdSql.checkData(0,4,-9.99000)
# bug fix
# bug fix
tdSql.query("select last_row(abs(c1)) from testdb.ct1")
tdSql.query("select last_row(abs(c1)) from testdb.ct1")
tdSql.checkData(0,0,9)
tdSql.checkData(0,0,9)
# # bug fix
# # bug fix
tdSql.query("select last_row(c1+1) from testdb.ct1")
tdSql.query("select last_row(c1+1) from testdb.ct1")
tdSql.query("select last_row(c1+1) from testdb.stb1")
tdSql.query("select last_row(c1+1) from testdb.stb1")
tdSql.query("select last_row(c1+1) from testdb.t1")
tdSql.query("select last_row(c1+1) from testdb.t1")
# used for stable table
# used for stable table
tdSql.query("select last_row(c1 ,c2 ,c3) ,last_row(c4) from testdb.ct1")
tdSql.query("select last_row(c1 ,c2 ,c3) ,last_row(c4) from testdb.ct1")
...
@@ -329,7 +329,7 @@ class TDTestCase:
...
@@ -329,7 +329,7 @@ class TDTestCase:
tdSql.checkData(0,2,-999)
tdSql.checkData(0,2,-999)
tdSql.checkData(0,3,None)
tdSql.checkData(0,3,None)
# bug need fix
# bug need fix
tdSql.query("select last_row(c1 ,c2 ,c3) from testdb.stb1 ")
tdSql.query("select last_row(c1 ,c2 ,c3) from testdb.stb1 ")
tdSql.checkData(0,0,None)
tdSql.checkData(0,0,None)
tdSql.checkData(0,1,None)
tdSql.checkData(0,1,None)
...
@@ -338,7 +338,7 @@ class TDTestCase:
...
@@ -338,7 +338,7 @@ class TDTestCase:
tdSql.query('select last_row(c1) from testdb.t1 where ts <"2022-12-31 01:01:36.000"')
tdSql.query('select last_row(c1) from testdb.t1 where ts <"2022-12-31 01:01:36.000"')
tdSql.checkData(0,0,8)
tdSql.checkData(0,0,8)
# bug need fix
# bug need fix
tdSql.query("select abs(last_row(c1)-2)+max(c1),ceil(last_row(c4)-2) from testdb.stb1 where c4 is not null")
tdSql.query("select abs(last_row(c1)-2)+max(c1),ceil(last_row(c4)-2) from testdb.stb1 where c4 is not null")
tdSql.checkData(0,0,16.000000000)
tdSql.checkData(0,0,16.000000000)
tdSql.checkData(0,1,-101.000000000)
tdSql.checkData(0,1,-101.000000000)
...
@@ -371,7 +371,7 @@ class TDTestCase:
...
@@ -371,7 +371,7 @@ class TDTestCase:
tdSql.query("select last_row(c1) ,count(*) from testdb.stb1 where c1 is null")
tdSql.query("select last_row(c1) ,count(*) from testdb.stb1 where c1 is null")
tdSql.checkData(0,0,None)
tdSql.checkData(0,0,None)
tdSql.checkData(0,1,3)
tdSql.checkData(0,1,3)
tdSql.query("select last_row(c1) ,count(c1) from testdb.stb1 where c1 is null")
tdSql.query("select last_row(c1) ,count(c1) from testdb.stb1 where c1 is null")
tdSql.checkData(0,0,None)
tdSql.checkData(0,0,None)
tdSql.checkData(0,1,0)
tdSql.checkData(0,1,0)
...
@@ -380,7 +380,7 @@ class TDTestCase:
...
@@ -380,7 +380,7 @@ class TDTestCase:
tdSql.query("select tbname ,last_row(c1) from testdb.stb1")
tdSql.query("select tbname ,last_row(c1) from testdb.stb1")
tdSql.checkData(0,0,'ct4')
tdSql.checkData(0,0,'ct4')
tdSql.checkData(0,1,None)
tdSql.checkData(0,1,None)
tdSql.query(" select tbname ,last_row(c1) from testdb.stb1 partition by tbname order by tbname ")
tdSql.query(" select tbname ,last_row(c1) from testdb.stb1 partition by tbname order by tbname ")
tdSql.checkData(0,0,'ct1')
tdSql.checkData(0,0,'ct1')
tdSql.checkData(0,1,9)
tdSql.checkData(0,1,9)
...
@@ -396,11 +396,11 @@ class TDTestCase:
...
@@ -396,11 +396,11 @@ class TDTestCase:
tdSql.query(" select t1 ,count(c1) from testdb.stb1 partition by t1 ")
tdSql.query(" select t1 ,count(c1) from testdb.stb1 partition by t1 ")
tdSql.checkRows(2)
tdSql.checkRows(2)
# filter by tbname
# filter by tbname
tdSql.query("select last_row(c1) from testdb.stb1 where tbname = 'ct1' ")
tdSql.query("select last_row(c1) from testdb.stb1 where tbname = 'ct1' ")
tdSql.checkData(0,0,9)
tdSql.checkData(0,0,9)
# bug need fix
# bug need fix
tdSql.query("select tbname ,last_row(c1) from testdb.stb1 where tbname = 'ct1' ")
tdSql.query("select tbname ,last_row(c1) from testdb.stb1 where tbname = 'ct1' ")
tdSql.checkData(0,1,9)
tdSql.checkData(0,1,9)
tdSql.query("select tbname ,last_row(c1) from testdb.stb1 partition by tbname order by tbname")
tdSql.query("select tbname ,last_row(c1) from testdb.stb1 partition by tbname order by tbname")
...
@@ -428,7 +428,7 @@ class TDTestCase:
...
@@ -428,7 +428,7 @@ class TDTestCase:
tdSql.checkData(0,2,333)
tdSql.checkData(0,2,333)
tdSql.checkData(0,3,3)
tdSql.checkData(0,3,3)
# filter by tag
# filter by tag
tdSql.query("select tbname ,last_row(c1) from testdb.stb1 where t1 =0 ")
tdSql.query("select tbname ,last_row(c1) from testdb.stb1 where t1 =0 ")
tdSql.checkData(0,1,9)
tdSql.checkData(0,1,9)
tdSql.query("select tbname ,last_row(c1) ,t1 from testdb.stb1 partition by t1 order by t1")
tdSql.query("select tbname ,last_row(c1) ,t1 from testdb.stb1 partition by t1 order by t1")
...
@@ -437,7 +437,7 @@ class TDTestCase:
...
@@ -437,7 +437,7 @@ class TDTestCase:
tdSql.checkData(1,0,'ct4')
tdSql.checkData(1,0,'ct4')
tdSql.checkData(1,1,None)
tdSql.checkData(1,1,None)
# filter by col
# filter by col
tdSql.query("select tbname ,last_row(c1),abs(c1)from testdb.stb1 where c1 =1;")
tdSql.query("select tbname ,last_row(c1),abs(c1)from testdb.stb1 where c1 =1;")
tdSql.checkData(0,0,'ct1')
tdSql.checkData(0,0,'ct1')
...
@@ -445,7 +445,7 @@ class TDTestCase:
...
@@ -445,7 +445,7 @@ class TDTestCase:
tdSql.checkData(0,2,1)
tdSql.checkData(0,2,1)
tdSql.query("select last_row(c1) from testdb.stb1 where abs(ceil(c1))*c1==1")
tdSql.query("select last_row(c1) from testdb.stb1 where abs(ceil(c1))*c1==1")
tdSql.checkData(0,0,1)
tdSql.checkData(0,0,1)
# mix with common functions
# mix with common functions
tdSql.query("select last_row(*) ,last(*) from testdb.stb1 ")
tdSql.query("select last_row(*) ,last(*) from testdb.stb1 ")
tdSql.checkRows(1)
tdSql.checkRows(1)
...
@@ -457,11 +457,11 @@ class TDTestCase:
...
@@ -457,11 +457,11 @@ class TDTestCase:
tdSql.query("select last_row(c1+abs(c1)) from testdb.stb1 partition by tbname order by tbname")
tdSql.query("select last_row(c1+abs(c1)) from testdb.stb1 partition by tbname order by tbname")
tdSql.query("select last(c1), max(c1+abs(c1)),last_row(c1+abs(c1)) from testdb.stb1 partition by tbname order by tbname")
tdSql.query("select last(c1), max(c1+abs(c1)),last_row(c1+abs(c1)) from testdb.stb1 partition by tbname order by tbname")
# # bug need fix ,taosd crash
# # bug need fix ,taosd crash
tdSql.error("select last_row(*) ,last(*) from testdb.stb1 partition by tbname order by last(*)")
tdSql.error("select last_row(*) ,last(*) from testdb.stb1 partition by tbname order by last(*)")
tdSql.error("select last_row(*) ,last(*) from testdb.stb1 partition by tbname order by last_row(*)")
tdSql.error("select last_row(*) ,last(*) from testdb.stb1 partition by tbname order by last_row(*)")
# mix with agg functions
# mix with agg functions
tdSql.query("select last(*), last_row(*),last(c1), last_row(c1) from testdb.stb1 ")
tdSql.query("select last(*), last_row(*),last(c1), last_row(c1) from testdb.stb1 ")
tdSql.query("select last(*), last_row(*),last(c1), last_row(c1) from testdb.ct1 ")
tdSql.query("select last(*), last_row(*),last(c1), last_row(c1) from testdb.ct1 ")
tdSql.query("select last(*), last_row(*),last(c1+1)*max(c1), last_row(c1+2)/2 from testdb.t1 ")
tdSql.query("select last(*), last_row(*),last(c1+1)*max(c1), last_row(c1+2)/2 from testdb.t1 ")
...
@@ -564,7 +564,7 @@ class TDTestCase:
...
@@ -564,7 +564,7 @@ class TDTestCase:
# bug need fix
# bug need fix
tdSql.query(" select sum(c1) from testdb.stb1 where t1+10 >1; ")
tdSql.query(" select sum(c1) from testdb.stb1 where t1+10 >1; ")
tdSql.query("select c1 ,t1 from testdb.stb1 where t1 =0 ")
tdSql.query("select c1 ,t1 from testdb.stb1 where t1 =0 ")
tdSql.checkRows(13)
tdSql.checkRows(13)
tdSql.query("select last_row(c1,t1) from testdb.stb1 ")
tdSql.query("select last_row(c1,t1) from testdb.stb1 ")
...
@@ -627,8 +627,8 @@ class TDTestCase:
...
@@ -627,8 +627,8 @@ class TDTestCase:
tdSql.execute(" use testdb ")
tdSql.execute(" use testdb ")
tdSql.query(" select last_row(c1) from testdb.stb1 group by t1 order by t1 ")
tdSql.query(" select last_row(c1) from testdb.stb1 group by t1 order by t1 ")
tdSql.checkRows(2)
tdSql.checkRows(2)
# bug need fix
# bug need fix
tdSql.query("select last_row(c1) from testdb.stb1 group by c1 order by c1,t1 ")
tdSql.query("select last_row(c1) from testdb.stb1 group by c1 order by c1,t1 ")
tdSql.checkRows(10)
tdSql.checkRows(10)
tdSql.checkData(9,0,8)
tdSql.checkData(9,0,8)
...
@@ -643,7 +643,7 @@ class TDTestCase:
...
@@ -643,7 +643,7 @@ class TDTestCase:
tdSql.checkRows(11)
tdSql.checkRows(11)
tdSql.checkData(10,0,9)
tdSql.checkData(10,0,9)
# bug need fix , result is error
# bug need fix , result is error
tdSql.query("select last_row(c1) from testdb.ct4 group by c1 order by t1 ")
tdSql.query("select last_row(c1) from testdb.ct4 group by c1 order by t1 ")
tdSql.query("select last_row(t1) from testdb.ct4 group by c1 order by t1 ")
tdSql.query("select last_row(t1) from testdb.ct4 group by c1 order by t1 ")
...
@@ -661,24 +661,24 @@ class TDTestCase:
...
@@ -661,24 +661,24 @@ class TDTestCase:
tdSql.query("select last_row(c1+c3) from testdb.stb1 group by abs(c1+c3) order by abs(c1+c3)")
tdSql.query("select last_row(c1+c3) from testdb.stb1 group by abs(c1+c3) order by abs(c1+c3)")
tdSql.checkRows(11)
tdSql.checkRows(11)
# bug need fix , taosd crash
# bug need fix , taosd crash
tdSql.query("select last_row(c1+c3)+c2 from testdb.stb1 group by abs(c1+c3)+c2 order by abs(c1+c3)+c2")
tdSql.query("select last_row(c1+c3)+c2 from testdb.stb1 group by abs(c1+c3)+c2 order by abs(c1+c3)+c2")
tdSql.checkRows(11)
tdSql.checkRows(11)
tdSql.query("select last_row(c1+c3)+last_row(c2) from testdb.stb1 group by abs(c1+c3)+abs(c2) order by abs(c1+c3)+abs(c2)")
tdSql.query("select last_row(c1+c3)+last_row(c2) from testdb.stb1 group by abs(c1+c3)+abs(c2) order by abs(c1+c3)+abs(c2)")
tdSql.checkRows(11)
tdSql.checkRows(11)
tdSql.checkData(0,0,None)
tdSql.checkData(0,0,None)
tdSql.checkData(2,0,11223.000000000)
tdSql.checkData(2,0,11223.000000000)
tdSql.query("select last_row(t1) from testdb.stb1 where abs(c1+t1)=1 partition by tbname")
tdSql.query("select last_row(t1) from testdb.stb1 where abs(c1+t1)=1 partition by tbname")
tdSql.checkData(0,0,1)
tdSql.checkData(0,0,1)
tdSql.query("select tbname , last_row(c1) from testdb.stb1 partition by tbname order by tbname")
tdSql.query("select tbname , last_row(c1) from testdb.stb1 partition by tbname order by tbname")
tdSql.checkRows(2)
tdSql.checkRows(2)
tdSql.checkData(0,0,'ct1')
tdSql.checkData(0,0,'ct1')
tdSql.checkData(0,1,9)
tdSql.checkData(0,1,9)
tdSql.checkData(0,2,'ct4')
tdSql.checkData(0,2,'ct4')
tdSql.checkData(0,3,None)
tdSql.checkData(0,3,None)
tdSql.query("select tbname , last_row(c1) from testdb.stb1 partition by t1 order by t1")
tdSql.query("select tbname , last_row(c1) from testdb.stb1 partition by t1 order by t1")
tdSql.checkRows(2)
tdSql.checkRows(2)
tdSql.checkData(0,0,'ct1')
tdSql.checkData(0,0,'ct1')
...
@@ -686,7 +686,7 @@ class TDTestCase:
...
@@ -686,7 +686,7 @@ class TDTestCase:
tdSql.checkData(0,2,'ct4')
tdSql.checkData(0,2,'ct4')
tdSql.checkData(0,3,None)
tdSql.checkData(0,3,None)
# bug need fix
# bug need fix
tdSql.query("select tbname , last_row(c1) from testdb.stb1 partition by c2 order by c1")
tdSql.query("select tbname , last_row(c1) from testdb.stb1 partition by c2 order by c1")
tdSql.checkRows(11)
tdSql.checkRows(11)
tdSql.checkData(10,1,9)
tdSql.checkData(10,1,9)
...
@@ -700,7 +700,7 @@ class TDTestCase:
...
@@ -700,7 +700,7 @@ class TDTestCase:
tdSql.query("select abs(c1) ,c2 ,t1, last_row(t1) from testdb.stb1 partition by c2 order by t1")
tdSql.query("select abs(c1) ,c2 ,t1, last_row(t1) from testdb.stb1 partition by c2 order by t1")
tdSql.checkRows(11)
tdSql.checkRows(11)
tdSql.query("select t1 ,last_row(t1) ,c2 from testdb.stb1 partition by c2 order by t1")
tdSql.query("select t1 ,last_row(t1) ,c2 from testdb.stb1 partition by c2 order by t1")
tdSql.checkRows(11)
tdSql.checkRows(11)
...
@@ -722,10 +722,18 @@ class TDTestCase:
...
@@ -722,10 +722,18 @@ class TDTestCase:
tdSql.query("select last_row(ceil(c1-2)) , abs(floor(t1+1)) ,floor(c2-c1) from testdb.stb1 partition by abs(floor(c1)) order by abs(c1)")
tdSql.query("select last_row(ceil(c1-2)) , abs(floor(t1+1)) ,floor(c2-c1) from testdb.stb1 partition by abs(floor(c1)) order by abs(c1)")
tdSql.checkRows(11)
tdSql.checkRows(11)
# interval
tdSql.query("select max(c1) from stb1 interval(50s) sliding(30s)")
tdSql.checkRows(13)
tdSql.query("select unique(c1) from stb1 partition by tbname")
# interval
tdSql.query("select last_row(c1) from testdb.stb1 interval(50s) sliding(30s)")
tdSql.query("select last_row(c1) from testdb.stb1 interval(50s) sliding(30s)")
tdSql.checkRows(27)
tdSql.checkRows(27)
tdSql.query("select last_row(c1) from testdb.ct1 interval(50s) sliding(30s)")
tdSql.query("select last_row(c1) from testdb.ct1 interval(50s) sliding(30s)")
tdSql.checkRows(5)
tdSql.checkRows(5)
last_row_result=tdSql.queryResult
last_row_result=tdSql.queryResult
...
@@ -745,13 +753,13 @@ class TDTestCase:
...
@@ -745,13 +753,13 @@ class TDTestCase:
tdSql.query('select last_row(c1) from testdb.stb1 where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s)')
tdSql.query('select last_row(c1) from testdb.stb1 where ts>="2022-07-06 16:00:00.000 " and ts < "2022-07-06 17:00:00.000 " interval(50s) sliding(30s)')
tdSql.query('select last_row(c1) from (select ts , c1 from testdb.t1 where ts>="2021-01-01 01:01:06.000" and ts < "2021-07-21 01:01:01.000" ) interval(10s) sliding(5s)')
tdSql.query('select last_row(c1) from (select ts , c1 from testdb.t1 where ts>="2021-01-01 01:01:06.000" and ts < "2021-07-21 01:01:01.000" ) interval(10s) sliding(5s)')
# join
# join
tdSql.query("use test")
tdSql.query("use test")
tdSql.query("select last(sub_tb_1.c1), last(sub_tb_2.c2) from sub_tb_1, sub_tb_2 where sub_tb_1.ts=sub_tb_2.ts")
tdSql.query("select last(sub_tb_1.c1), last(sub_tb_2.c2) from sub_tb_1, sub_tb_2 where sub_tb_1.ts=sub_tb_2.ts")
tdSql.checkCols(2)
tdSql.checkCols(2)
last_row_result=tdSql.queryResult
last_row_result=tdSql.queryResult
tdSql.query("select last_row(sub_tb_1.c1), last_row(sub_tb_2.c2) from sub_tb_1, sub_tb_2 where sub_tb_1.ts=sub_tb_2.ts")
tdSql.query("select last_row(sub_tb_1.c1), last_row(sub_tb_2.c2) from sub_tb_1, sub_tb_2 where sub_tb_1.ts=sub_tb_2.ts")
forind,rowinenumerate(last_row_result):
forind,rowinenumerate(last_row_result):
tdSql.checkData(ind,0,row[0])
tdSql.checkData(ind,0,row[0])
...
@@ -769,7 +777,7 @@ class TDTestCase:
...
@@ -769,7 +777,7 @@ class TDTestCase:
tdSql.query("select last_row(*), last(*) from sub_tb_1, sub_tb_2 where sub_tb_1.ts=sub_tb_2.ts")
tdSql.query("select last_row(*), last(*) from sub_tb_1, sub_tb_2 where sub_tb_1.ts=sub_tb_2.ts")
forind,rowinenumerate(last_row_result):
forind,rowinenumerate(last_row_result):
tdSql.checkData(ind,0,row[0])
tdSql.checkData(ind,0,row[0])
defsupport_super_table_test(self):
defsupport_super_table_test(self):
tdSql.execute(" use testdb ")
tdSql.execute(" use testdb ")
...
@@ -783,9 +791,9 @@ class TDTestCase:
...
@@ -783,9 +791,9 @@ class TDTestCase:
self.check_result_auto(" select t3,c1 from testdb.stb1 where c1 > 0 order by tbname ","select t3 ,abs(c1) from testdb.stb1 where c1 > 0 order by tbname")
self.check_result_auto(" select t3,c1 from testdb.stb1 where c1 > 0 order by tbname ","select t3 ,abs(c1) from testdb.stb1 where c1 > 0 order by tbname")
self.check_result_auto(" select t4,c1 from testdb.stb1 where c1 > 0 order by tbname ","select t4 , abs(c1) from testdb.stb1 where c1 > 0 order by tbname")
self.check_result_auto(" select t4,c1 from testdb.stb1 where c1 > 0 order by tbname ","select t4 , abs(c1) from testdb.stb1 where c1 > 0 order by tbname")
tdSql.execute("create table random_measure2_1 (ts timestamp,ela float, name binary(40))")
tdSql.execute("create table random_measure2_1 (ts timestamp,ela float, name binary(40))")
tdSql.query("SELECT ts,diff(mv) AS difka FROM (SELECT ts,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name,ts interval(10m) fill(value,0)) GROUP BY name,ts;")
tdSql.query("SELECT ts,diff(mv) AS difka FROM (SELECT ts,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name,ts interval(10m) fill(value,0)) GROUP BY name,ts;")
tdSql.query("select name,diff(mv) AS difka FROM (SELECT ts,name,mv FROM (SELECT _wstart as ts,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0))) group BY name ;")
tdSql.query("SELECT _wstart,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0)")
tdSql.query("SELECT _wstart,name,floor(avg(velocity)/10)/floor(avg(velocity)/10) AS mv FROM readings WHERE name!='' AND ts > '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition by name interval(10m) fill(value,0)")
# 7. avg-load
# 7. avg-load
...
@@ -124,9 +125,16 @@ class TDTestCase:
...
@@ -124,9 +125,16 @@ class TDTestCase:
#it's already supported:
#it's already supported:
# last-loc
# last-loc
tdSql.query("")
tdSql.query("SELECT last_row(ts),latitude,longitude,name,driver FROM readings WHERE fleet='South' and name IS NOT NULL partition BY name,driver order by name ;")
tdSql.query("SELECT last_row(ts),name,driver,fuel_state,driver FROM diagnostics WHERE fuel_state <= 0.1 AND fleet = 'South' and name IS NOT NULL GROUP BY name,driver order by name;")
# 3. avg-vs-projected-fuel-consumption
tdSql.query("select avg(fuel_consumption) as avg_fuel_consumption,avg(nominal_fuel_consumption) as nominal_fuel_consumption from readings where velocity > 1 group by fleet")
defrun(self):
tdLog.printNoPrefix("==========step1:create database and table,insert data ==============")
tdLog.printNoPrefix("==========step1:create database and table,insert data ==============")