This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new bee298275d2 Allow inserting negative timestamp type of value
bee298275d2 is described below
commit bee298275d206a38f4bb431fac1540fa6e292f16
Author: Haonan <[email protected]>
AuthorDate: Thu Jul 11 08:57:41 2024 +0800
Allow inserting negative timestamp type of value
---
.../apache/iotdb/db/it/IoTDBInsertWithQueryIT.java | 34 ++++++++++++++++++++++
.../org/apache/iotdb/db/utils/CommonUtils.java | 2 +-
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBInsertWithQueryIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBInsertWithQueryIT.java
index 2ef61ed7b28..d237423c52f 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBInsertWithQueryIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBInsertWithQueryIT.java
@@ -162,6 +162,10 @@ public class IoTDBInsertWithQueryIT {
selectAndCount(2001);
negativeTimestampAggregationTest();
+
+ insertNegativeTimestampTypeData();
+
+ queryNegativeTimestampTypeDataTest();
}
@Test
@@ -423,6 +427,36 @@ public class IoTDBInsertWithQueryIT {
}
}
+ private void insertNegativeTimestampTypeData() {
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.execute("create timeseries root.fans.d0.s2 with datatype =
timestamp");
+ statement.execute(
+ String.format(
+ "insert into root.fans.d0(time,s2) values(%s,%s)",
+ Long.MIN_VALUE + 1, Long.MIN_VALUE + 1));
+ statement.execute("insert into root.fans.d0(time,s2)
values(-999999,-9999999)");
+ statement.execute(
+ "insert into root.fans.d0(time,s2) values(1900-01-01
10:00:00,1900-01-01 10:00:00)");
+ } catch (SQLException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ private void queryNegativeTimestampTypeDataTest() {
+ String[] expectedHeader =
+ new String[] {
+ "Time", "root.fans.d0.s2",
+ };
+ String[] retArray =
+ new String[] {
+ "-9223372036854775807,-9223372036854775807,",
+ "-2208952800000,-2208952800000,",
+ "-999999,-9999999,"
+ };
+ resultSetEqualTest("SELECT s2 FROM root.fans.d0;", expectedHeader,
retArray);
+ }
+
private void flush() {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/CommonUtils.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/CommonUtils.java
index 04bbb4221e6..d7489730613 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/CommonUtils.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/CommonUtils.java
@@ -87,7 +87,7 @@ public class CommonUtils {
}
case TIMESTAMP:
try {
- if (StringUtils.isNumeric(value)) {
+ if (TypeInferenceUtils.isNumber(value)) {
return Long.parseLong(value);
} else {
return
DateTimeUtils.parseDateTimeExpressionToLong(StringUtils.trim(value), zoneId);