This is an automated email from the ASF dual-hosted git repository.
JackieTien97 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 07e2cfb63f4 fix(tvf): validate non-negative width and height in
pattern_match (#17515)
07e2cfb63f4 is described below
commit 07e2cfb63f4682bf28b2f44c9779ea7f089e9f7e
Author: Lin Xintao <[email protected]>
AuthorDate: Sun Apr 19 15:10:10 2026 +0800
fix(tvf): validate non-negative width and height in pattern_match (#17515)
---
.../apache/iotdb/relational/it/db/it/IoTDBWindowTVFIT.java | 12 ++++++++++++
.../relational/function/tvf/PatternMatchTableFunction.java | 8 ++++++++
2 files changed, 20 insertions(+)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBWindowTVFIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBWindowTVFIT.java
index 7b6390f84e1..dc12a4ec098 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBWindowTVFIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBWindowTVFIT.java
@@ -881,5 +881,17 @@ public class IoTDBWindowTVFIT {
"select * from pattern_match(data => t1 ORDER BY time, time_col =>
'time', data_col => 'value', pattern => '1.0,2.0,1.0', smooth => 0.5, threshold
=> -1.1, width => 1000.0, height => 500.0, smooth_on_pattern => false)",
"threshold must be a non-negative number",
DATABASE_NAME);
+
+ // test negative width should be rejected
+ tableAssertTestFail(
+ "select * from pattern_match(data => t1 ORDER BY time, time_col =>
'time', data_col => 'value', pattern => '1.0,2.0,1.0', smooth => 0.5, threshold
=> 10.0, width => -1.0, height => 500.0, smooth_on_pattern => false)",
+ "width must be a non-negative number",
+ DATABASE_NAME);
+
+ // test negative height should be rejected
+ tableAssertTestFail(
+ "select * from pattern_match(data => t1 ORDER BY time, time_col =>
'time', data_col => 'value', pattern => '1.0,2.0,1.0', smooth => 0.5, threshold
=> 10.0, width => 1000.0, height => -10.0, smooth_on_pattern => false)",
+ "height must be a non-negative number",
+ DATABASE_NAME);
}
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/PatternMatchTableFunction.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/PatternMatchTableFunction.java
index c2ed8c0ead0..bc9ae1f57f9 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/PatternMatchTableFunction.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/function/tvf/PatternMatchTableFunction.java
@@ -107,12 +107,20 @@ public class PatternMatchTableFunction implements
TableFunction {
Double smoothValue = (Double) ((ScalarArgument)
arguments.get(SMOOTH_PARAM)).getValue();
Double thresholdValue = (Double) ((ScalarArgument)
arguments.get(THRESHOLD_PARAM)).getValue();
+ Double widthValue = (Double) ((ScalarArgument)
arguments.get(WIDTH_PARAM)).getValue();
+ Double heightValue = (Double) ((ScalarArgument)
arguments.get(HEIGHT_PARAM)).getValue();
if (smoothValue < 0) {
throw new UDFException("smooth must be a non-negative number, but got: "
+ smoothValue);
}
if (thresholdValue < 0) {
throw new UDFException("threshold must be a non-negative number, but
got: " + thresholdValue);
}
+ if (widthValue < 0) {
+ throw new UDFException("width must be a non-negative number, but got: "
+ widthValue);
+ }
+ if (heightValue < 0) {
+ throw new UDFException("height must be a non-negative number, but got: "
+ heightValue);
+ }
// outputColumnSchema description
DescribedSchema properColumnSchema =