You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2024/09/24 07:08:50 UTC

(iotdb) branch chenge_insert_error_info created (now 1728c1d06c9)

This is an automated email from the ASF dual-hosted git repository.

haonan pushed a change to branch chenge_insert_error_info
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 1728c1d06c9 Change the error infomation when insert a timestamp over Long.MaxValue

This branch includes the following new commits:

     new 1728c1d06c9 Change the error infomation when insert a timestamp over Long.MaxValue

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(iotdb) 01/01: Change the error infomation when insert a timestamp over Long.MaxValue

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch chenge_insert_error_info
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 1728c1d06c97e5b002b61dd552911cad539fd28d
Author: HTHou <hh...@outlook.com>
AuthorDate: Tue Sep 24 15:08:23 2024 +0800

    Change the error infomation when insert a timestamp over Long.MaxValue
---
 .../relational/it/query/old/IoTDBDatetimeFormatTableIT.java | 13 +++++++++++++
 .../apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java |  6 +++++-
 .../resources/conf/iotdb-system.properties.template         |  3 ++-
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/IoTDBDatetimeFormatTableIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/IoTDBDatetimeFormatTableIT.java
index c9a48c6f168..9e1dcac7783 100644
--- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/IoTDBDatetimeFormatTableIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/IoTDBDatetimeFormatTableIT.java
@@ -153,5 +153,18 @@ public class IoTDBDatetimeFormatTableIT {
       e.printStackTrace();
       fail();
     }
+
+    try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+        Statement statement = connection.createStatement()) {
+      statement.execute("use " + DATABASE_NAME);
+      statement.execute(
+          "insert into table1(time,device_id,s2) values (16182830055860000000, 'd2',8.76)");
+      fail();
+    } catch (SQLException e) {
+      e.printStackTrace();
+      Assert.assertTrue(
+          e.getMessage()
+              .contains("please check whether the timestamp 16182830055860000000 is correct."));
+    }
   }
 }
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
index f184d34dba0..6377a72c843 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
@@ -257,6 +257,7 @@ import java.util.stream.Collectors;
 import static org.apache.iotdb.commons.schema.SchemaConstant.ALL_RESULT_NODES;
 import static org.apache.iotdb.db.queryengine.plan.optimization.LimitOffsetPushDown.canPushDownLimitOffsetToGroupByTime;
 import static org.apache.iotdb.db.queryengine.plan.optimization.LimitOffsetPushDown.pushDownLimitOffsetToTimeParameter;
+import static org.apache.iotdb.db.utils.TimestampPrecisionUtils.TIMESTAMP_PRECISION;
 import static org.apache.iotdb.db.utils.TimestampPrecisionUtils.currPrecision;
 import static org.apache.iotdb.db.utils.constant.SqlConstant.CAST_FUNCTION;
 import static org.apache.iotdb.db.utils.constant.SqlConstant.CAST_TYPE;
@@ -1992,7 +1993,10 @@ public class ASTVisitor extends IoTDBSqlParserBaseVisitor<Statement> {
         return Long.parseLong(constant.INTEGER_LITERAL().getText());
       } catch (NumberFormatException e) {
         throw new SemanticException(
-            String.format("Can not parse %s to long value", constant.INTEGER_LITERAL().getText()));
+            String.format(
+                "Current system timestamp precision is %s, "
+                    + "please check whether the timestamp %s is correct.",
+                TIMESTAMP_PRECISION, constant.INTEGER_LITERAL().getText()));
       }
     } else if (constant.dateExpression() != null) {
       return parseDateExpression(constant.dateExpression(), CommonDateTimeUtils.currentTime());
diff --git a/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template b/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template
index 945199534fc..032a9030656 100644
--- a/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template
+++ b/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-system.properties.template
@@ -1042,6 +1042,7 @@ expired_data_ratio=0.3
 timestamp_precision=ms
 
 # When the timestamp precision check is enabled, the timestamps those are over 13 digits for ms precision, or over 16 digits for us precision are not allowed to be inserted.
+# For all precisions, ms, us and ns, the timestamps cannot exceed the range of [-9223372036854775808, 9223372036854775807], regardless of whether the check is enabled or not.
 # effectiveMode: first_start
 # Datatype: Boolean
 timestamp_precision_check_enabled=true
@@ -1948,4 +1949,4 @@ write_request_remote_dispatch_max_retry_duration_in_ms=60000
 # Current unknown errors includes EXECUTE_STATEMENT_ERROR(301) and INTERNAL_SERVER_ERROR(305)
 # effectiveMode: hot_reload
 # Datatype: boolean
-enable_retry_for_unknown_error=false
\ No newline at end of file
+enable_retry_for_unknown_error=false