I write data to cnosdb through jdbc, and the data writing is successful, but the returned interface is not the number of rows but -1. What's going on?

huangapple go评论92阅读模式
英文:

I write data to cnosdb through jdbc, and the data writing is successful, but the returned interface is not the number of rows but -1. What's going on?

问题

通过JDBC将数据写入cnosdb,数据写入成功,但返回的接口不是行数而是-1。发生了什么事情?我的代码如下:

步骤:

  1. 创建数据库:
boolean rs002 = stmt.execute("CREATE DATABASE tc_between WITH TTL '100000d';");
assertFalse(rs002);
  1. 创建表格:
boolean rs004 = stmt001.execute("CREATE TABLE IF NOT EXISTS m2(f0 BIGINT UNSIGNED, f1 BIGINT, TAGS(t0, t1));");
assertFalse(rs004);
  1. 在表格中插入数据:
int rs005 = stmt001.executeUpdate("INSERT m2(TIME, t0, f0, t1, f1) VALUES(CAST (1672301798050000000 AS TIMESTAMP), 'Ig.UZ', 531136669299148225, 'nA4C3DH~B ', 9223372036854775807),(CAST (1672301798060000000 AS TIMESTAMP), '263356943', 1040920791041719924, '', -9223372036854775807),(CAST (1672301798070000000 AS TIMESTAMP), '1040920791041719924', 442061994865016078, 'gE1B7c.', 0);");
System.out.println(rs005);
int rs006 = stmt001.executeUpdate("INSERT m2(TIME, t0, f0, t1, f1) VALUES(CAST (3031647407609562138 AS TIMESTAMP), '1D75h', 4166390262642105876, '7ua', 0.0),(CAST (1079616064603730664 AS TIMESTAMP), '}', 7806435932478031652, 'EA26qy', 23.456), (CAST (263356943 AS TIMESTAMP), '0.6287658423307444', 5466573340614276155, ',JC51Fh', -23.456), (CAST (1742494251700243812 AS TIMESTAMP), '#f^uE1B7KruC7BFz', 196790207, 'aF', 0.123);");
assertEquals(4, rs006);
int rs007 = stmt001.executeUpdate("INSERT m2(TIME, t0, f0, t1, f1) VALUES(CAST (3584132160280509277 AS TIMESTAMP), '', 4132058214182166915, 'V*1lE/', -0.123);");
assertEquals(1, rs007);
ResultSet rs008 = stmt001.executeQuery("SELECT m2.f0 FROM m2 WHERE CAST(0 AS STRING) BETWEEN (CAST( starts_with(m2.t0, m2.t1) AS STRING)) AND (m2.t1);");
rs008.next();
System.out.println(rs008.getString(1));
stmt001.close();
conn001.close();

日志如下:

[ERROR] AppTest.test_Jdbc_betweensql:66 expected:<4> but was:<-1>

然后检查cnosdb信息,如下:

log 2
tc_between  select * from m2;
+-------------------------------+---------------------+------------+---------------------+----------------------+

| time                          | t0                  | t1         | f0                  | f1                   |
+-------------------------------+---------------------+------------+---------------------+----------------------+
| 2025-03-20T18:10:51.700243812 | #f^uE1B7KruC7BFz    | aF         | 196790207           | 0                    |
| 2004-03-18T13:21:04.603730664 | }                   | EA26qy     | 7806435932478031652 | 23                   |
| 2066-01-25T12:16:47.609562138 | 1D75h               | 7ua        | 4166390262642105876 | 0                    |
| 2022-12-29T08:16:38.070       | 1040920791041719924 | gE1B7c.    | 442061994865016078  | 0                    |
| 1970-01-01T00:00:00.263356943 | 0.6287658423307444  | ,JC51Fh    | 5466573340614276155 | -23                  |
| 2022-12-29T08:16:38.050       | Ig.UZ               | nA4C3DH~B  | 531136669299148225  | 9223372036854775807  |
| 2022-12-29T08:16:38.060       | 263356943           |            | 1040920791041719924 | -9223372036854775807 |
+-------------------------------+---------------------+------------+---------------------+----------------------+
Query took 0.100 seconds.
英文:

I write data to cnosdb through jdbc, and the data writing is successful, but the returned interface is not the number of rows but -1. What's going on?My code as follow:

step:

  1. creat a database;

    boolean rs002 = stmt.execute(&quot;CREATE DATABASE tc_between WITH TTL &#39;100000d&#39;;&quot;);
            assertFalse(rs002);
    
  2. create table;

    boolean rs004 = stmt001.execute(&quot;CREATE TABLE IF NOT EXISTS m2(f0 BIGINT UNSIGNED, f1 BIGINT, TAGS(t0, t1));&quot;);
            assertFalse(rs004);
    
  3. insert data in tables;

    
    
            int rs005 = stmt001.executeUpdate(&quot;INSERT m2(TIME, t0, f0, t1, f1) VALUES(CAST (1672301798050000000 AS TIMESTAMP), &#39;Ig.UZ&#39;, 531136669299148225, &#39;nA4C3DH~B &#39;, 9223372036854775807),(CAST (1672301798060000000 AS TIMESTAMP), &#39;263356943&#39;, 1040920791041719924, &#39;&#39;, -9223372036854775807),(CAST (1672301798070000000 AS TIMESTAMP), &#39;1040920791041719924&#39;, 442061994865016078, &#39;gE1B7c.&#39;, 0);&quot;);
            System.out.println(rs005);
            int rs006 = stmt001.executeUpdate(&quot;INSERT m2(TIME, t0, f0, t1, f1) VALUES(CAST (3031647407609562138 AS TIMESTAMP), &#39;1D75h&#39;, 4166390262642105876, &#39;7ua&#39;, 0.0),(CAST (1079616064603730664 AS TIMESTAMP), &#39;}&#39;, 7806435932478031652, &#39;EA26qy&#39;, 23.456), (CAST (263356943 AS TIMESTAMP), &#39;0.6287658423307444&#39;, 5466573340614276155, &#39;,JC51Fh&#39;, -23.456), (CAST (1742494251700243812 AS TIMESTAMP), &#39;#f^uE1B7KruC7BFz&#39;, 196790207, &#39;aF&#39;, 0.123);&quot;);
            assertEquals(4, rs006);
            int rs007 = stmt001.executeUpdate(&quot;INSERT m2(TIME, t0, f0, t1, f1) VALUES(CAST (3584132160280509277 AS TIMESTAMP), &#39;&#39;, 4132058214182166915, &#39;V*1lE/&#39;, -0.123);&quot;);
            assertEquals(1, rs007);
            ResultSet rs008 = stmt001.executeQuery(&quot;SELECT m2.f0 FROM m2 WHERE CAST(0 AS STRING) BETWEEN (CAST( starts_with(m2.t0, m2.t1) AS STRING)) AND (m2.t1);&quot;);
            rs008.next();
            System.out.println(rs008.getString(1));
            stmt001.close();
            conn001.close();
    

the logs as follow:

[ERROR]   AppTest.test_Jdbc_betweensql:66 expected:&lt;4&gt; but was:&lt;-1&gt;

and then check the cnosdb info, as follow:

log 2
tc_between ❯ select * from m2;
+-------------------------------+---------------------+------------+---------------------+----------------------+

| time                          | t0                  | t1         | f0                  | f1                   |
+-------------------------------+---------------------+------------+---------------------+----------------------+
| 2025-03-20T18:10:51.700243812 | #f^uE1B7KruC7BFz    | aF         | 196790207           | 0                    |
| 2004-03-18T13:21:04.603730664 | }                   | EA26qy     | 7806435932478031652 | 23                   |
| 2066-01-25T12:16:47.609562138 | 1D75h               | 7ua        | 4166390262642105876 | 0                    |
| 2022-12-29T08:16:38.070       | 1040920791041719924 | gE1B7c.    | 442061994865016078  | 0                    |
| 1970-01-01T00:00:00.263356943 | 0.6287658423307444  | ,JC51Fh    | 5466573340614276155 | -23                  |
| 2022-12-29T08:16:38.050       | Ig.UZ               | nA4C3DH~B  | 531136669299148225  | 9223372036854775807  |
| 2022-12-29T08:16:38.060       | 263356943           |            | 1040920791041719924 | -9223372036854775807 |
+-------------------------------+---------------------+------------+---------------------+----------------------+
Query took 0.100 seconds.

答案1

得分: 1

目前cnosdb-flight-sql尚未完全实现。

英文:

Currently cnosdb-flight-sql is not fully implemented.

huangapple
  • 本文由 发表于 2023年7月24日 18:26:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76753567.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定