You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2022/01/10 03:48:48 UTC

[iotdb] branch iotdb-2267 created (now cb4258b)

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

rong pushed a change to branch iotdb-2267
in repository https://gitbox.apache.org/repos/asf/iotdb.git.


      at cb4258b  [IOTDB-2267] Error code 500 caused by org.apache.iotdb.udf.UDTFExample

This branch includes the following new commits:

     new cb4258b  [IOTDB-2267] Error code 500 caused by org.apache.iotdb.udf.UDTFExample

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: [IOTDB-2267] Error code 500 caused by org.apache.iotdb.udf.UDTFExample

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

rong pushed a commit to branch iotdb-2267
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit cb4258b7534869159e77a64b8dd5e506ddc02fb4
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Mon Jan 10 11:48:02 2022 +0800

    [IOTDB-2267] Error code 500 caused by org.apache.iotdb.udf.UDTFExample
---
 .../src/main/java/org/apache/iotdb/udf/UDTFExample.java | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/example/udf/src/main/java/org/apache/iotdb/udf/UDTFExample.java b/example/udf/src/main/java/org/apache/iotdb/udf/UDTFExample.java
index 17a534d..9772a2b 100644
--- a/example/udf/src/main/java/org/apache/iotdb/udf/UDTFExample.java
+++ b/example/udf/src/main/java/org/apache/iotdb/udf/UDTFExample.java
@@ -23,11 +23,13 @@ import org.apache.iotdb.db.query.udf.api.UDTF;
 import org.apache.iotdb.db.query.udf.api.access.Row;
 import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
 import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
 import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
 import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 
 import java.io.IOException;
+import java.util.Map;
 
 /** This is an internal example of the UDTF implementation. */
 public class UDTFExample implements UDTF {
@@ -44,6 +46,21 @@ public class UDTFExample implements UDTF {
    * SELECT s1, example(s1), s2, example(s2) FROM root.sg1.d1;
    */
   @Override
+  public void validate(UDFParameterValidator validator) throws Exception {
+    validator
+        // this udf only accepts 1 time series
+        .validateInputSeriesNumber(1)
+        // the data type of the first input time series should be INT32
+        .validateInputSeriesDataType(0, TSDataType.INT32)
+        // this udf doesn't accept any extra parameters
+        // the validation rule is not required because extra parameters will be ignored
+        .validate(
+            attributes -> ((Map) attributes).isEmpty(),
+            "extra udf parameters are not allowed",
+            validator.getParameters().getAttributes());
+  }
+
+  @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) {
     configurations
         .setAccessStrategy(new RowByRowAccessStrategy())