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 2d0ba711075 Int + Date and Long + Date do not check if the date
exceeds the range
2d0ba711075 is described below
commit 2d0ba7110753811a3e94fb8d61936b886f763cbb
Author: FearfulTomcat27 <[email protected]>
AuthorDate: Fri Mar 14 16:26:08 2025 +0800
Int + Date and Long + Date do not check if the date exceeds the range
---
.../it/query/old/query/IoTDBArithmeticTableIT.java | 12 ++++++++++++
.../codegen/templates/ArithmeticBinaryColumnTransformer.ftl | 11 +++++++++++
2 files changed, 23 insertions(+)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBArithmeticTableIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBArithmeticTableIT.java
index 9ee662a3727..a78b87c081e 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBArithmeticTableIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBArithmeticTableIT.java
@@ -354,6 +354,18 @@ public class IoTDBArithmeticTableIT {
"752: Year must be between 1000 and 9999.",
"test");
+ tableAssertTestFail(
+ String.format(
+ "select %s + date from table2 where time = 1",
+ DateTimeUtils.correctPrecision(MILLISECONDS_IN_DAY)),
+ "752: Year must be between 1000 and 9999.",
+ "test");
+
+ tableAssertTestFail(
+ String.format("select %s + date from table2 where time = 1", 86400000),
+ "752: Year must be between 1000 and 9999.",
+ "test");
+
tableAssertTestFail(
String.format(
"select date - %s from table2 where time = 2",
diff --git
a/iotdb-core/datanode/src/main/codegen/templates/ArithmeticBinaryColumnTransformer.ftl
b/iotdb-core/datanode/src/main/codegen/templates/ArithmeticBinaryColumnTransformer.ftl
index 9fc7ef60a70..2e2c3f50f1c 100644
---
a/iotdb-core/datanode/src/main/codegen/templates/ArithmeticBinaryColumnTransformer.ftl
+++
b/iotdb-core/datanode/src/main/codegen/templates/ArithmeticBinaryColumnTransformer.ftl
@@ -184,8 +184,14 @@ import org.apache.tsfile.read.common.type.Type;
import org.apache.tsfile.utils.DateUtils;
import java.time.ZoneId;
+<#if second.instance == "DATE">
+import java.time.format.DateTimeParseException;
+</#if>
<#if first.dataType == "int" || second.dataType == "int" || first.dataType ==
"long" || second.dataType == "long">
+<#if second.instance == "DATE">
+import static org.apache.iotdb.rpc.TSStatusCode.DATE_OUT_OF_RANGE;
+</#if>
import static org.apache.iotdb.rpc.TSStatusCode.NUMERIC_VALUE_OUT_OF_RANGE;
</#if>
@@ -250,6 +256,11 @@ public class ${className} extends BinaryColumnTransformer {
String.format("long ${operator.name} overflow: %s + %s", left,
right),
NUMERIC_VALUE_OUT_OF_RANGE.getStatusCode(),
true);
+ }catch (DateTimeParseException e) {
+ throw new IoTDBRuntimeException(
+ "Year must be between 1000 and 9999.",
+ DATE_OUT_OF_RANGE.getStatusCode(),
+ true);
}
<#else>
try{