This is an automated email from the ASF dual-hosted git repository. haonan pushed a commit to branch ht/cp_0926 in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 4fdb2af9c01c8bbcc9047daf970e0e32ae0ed111 Author: Haonan <[email protected]> AuthorDate: Wed Sep 25 15:42:42 2024 +0800 Change the error infomation when insert a timestamp over Long.MaxValue (#13597) * Change the error infomation when insert a timestamp over Long.MaxValue * Change the error infomation when insert a timestamp over Long.MaxValue --- .../test/java/org/apache/iotdb/db/it/IoTDBDatetimeFormatIT.java | 9 +++++++++ .../org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java | 6 +++++- .../src/assembly/resources/conf/iotdb-system.properties.template | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDatetimeFormatIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDatetimeFormatIT.java index bb3a8de7d12..620043e6c7b 100644 --- a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDatetimeFormatIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDatetimeFormatIT.java @@ -128,5 +128,14 @@ public class IoTDBDatetimeFormatIT { e.printStackTrace(); fail(); } + try (Connection connection = EnvFactory.getEnv().getConnection(); + Statement statement = connection.createStatement()) { + statement.execute("insert into root.sg.d1(time,s2) values (16182830055860000000, 8.76);"); + fail(); + } catch (SQLException e) { + 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 bd481a8d3dd..8796c4e8b65 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 @@ -255,6 +255,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; @@ -1990,7 +1991,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
