我通过jdbc向cnosdb写入数据,数据写入成功,但是返回的接口不是行数而是-1。这是怎么回事?我的代码如下:
步骤:
创建数据库;
boolean rs002 = stmt.execute("CREATE DATABASE tc_between WITH TTL '100000d';");
assertFalse(rs002);
创建表;
boolean rs004 = stmt001.execute("CREATE TABLE IF NOT EXISTS m2(f0 BIGINT UNSIGNED, f1 BIGINT, TAGS(t0, t1));");
assertFalse(rs004);
在表中插入数据;
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.
目前cnosdb-flight-sql尚未完全实现。