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/05/20 18:55:33 UTC

[iotdb] 02/05: pre remove

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

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

commit 0def94fb18a89b11767843a44c8435a9e162ff85
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Sat May 21 01:24:38 2022 +0800

    pre remove
---
 .../query/expression/multi/FunctionExpression.java | 30 ++++++--
 .../api/customizer/parameter/UDFParameters.java    | 51 +++++---------
 .../api/customizer/strategy/AccessStrategy.java    | 12 +---
 .../strategy/SlidingTimeWindowAccessStrategy.java  | 80 +++++++---------------
 .../db/query/udf/core/executor/UDTFExecutor.java   | 64 +++++------------
 .../query/udf/core/executor/UDTFTypeInferrer.java  | 23 ++++---
 ...nputColumnSingleReferenceIntermediateLayer.java |  3 +-
 .../tv/ElasticSerializableBinaryTVList.java        |  4 +-
 .../tv/ElasticSerializableTVList.java              | 13 ++--
 .../udf/datastructure/tv/SerializableTVList.java   |  6 +-
 .../query/udf/service/UDFClassLoaderManager.java   |  3 +-
 .../query/udf/service/UDFRegistrationService.java  | 10 ++-
 .../db/tools/watermark/WatermarkDetector.java      |  9 +--
 .../ElasticSerializableTVListTest.java             | 12 ++--
 14 files changed, 124 insertions(+), 196 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/query/expression/multi/FunctionExpression.java b/server/src/main/java/org/apache/iotdb/db/query/expression/multi/FunctionExpression.java
index caa87859e6..12e6084a6a 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/expression/multi/FunctionExpression.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/expression/multi/FunctionExpression.java
@@ -240,7 +240,7 @@ public class FunctionExpression extends Expression {
     for (Expression expression : expressions) {
       expression.constructUdfExecutors(expressionName2Executor, zoneId);
     }
-    expressionName2Executor.put(expressionString, new UDTFExecutor(this, zoneId));
+    expressionName2Executor.put(expressionString, new UDTFExecutor(functionName, zoneId));
   }
 
   @Override
@@ -254,7 +254,15 @@ public class FunctionExpression extends Expression {
 
       if (isTimeSeriesGeneratingFunctionExpression()) {
         typeProvider.setType(
-            expressionString, new UDTFTypeInferrer(this).inferOutputType(typeProvider));
+            expressionString,
+            new UDTFTypeInferrer(functionName)
+                .inferOutputType(
+                    expressions.stream().map(Expression::toString).collect(Collectors.toList()),
+                    getPaths(),
+                    expressions.stream()
+                        .map(f -> typeProvider.getType(f.toString()))
+                        .collect(Collectors.toList()),
+                    functionAttributes));
       } else {
         if (expressions.size() != 1) {
           throw new SemanticException(
@@ -381,7 +389,15 @@ public class FunctionExpression extends Expression {
       throws QueryProcessException, IOException {
     UDTFExecutor executor = udtfContext.getExecutorByFunctionExpression(this);
 
-    executor.beforeStart(queryId, memoryAssigner.assign(), typeProvider);
+    executor.beforeStart(
+        queryId,
+        memoryAssigner.assign(),
+        expressions.stream().map(Expression::toString).collect(Collectors.toList()),
+        getPaths(),
+        expressions.stream()
+            .map(f -> typeProvider.getType(f.toString()))
+            .collect(Collectors.toList()),
+        functionAttributes);
 
     AccessStrategy accessStrategy = executor.getConfigurations().getAccessStrategy();
     switch (accessStrategy.getAccessStrategyType()) {
@@ -487,7 +503,13 @@ public class FunctionExpression extends Expression {
       throws QueryProcessException, IOException {
     UDTFExecutor executor = udtfContext.getExecutorByFunctionExpression(this);
 
-    executor.beforeStart(queryId, memoryAssigner.assign(), expressionDataTypeMap);
+    executor.beforeStart(
+        queryId,
+        memoryAssigner.assign(),
+        expressions.stream().map(Expression::toString).collect(Collectors.toList()),
+        getPaths(),
+        expressions.stream().map(expressionDataTypeMap::get).collect(Collectors.toList()),
+        functionAttributes);
 
     AccessStrategy accessStrategy = executor.getConfigurations().getAccessStrategy();
     switch (accessStrategy.getAccessStrategyType()) {
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/api/customizer/parameter/UDFParameters.java b/server/src/main/java/org/apache/iotdb/db/query/udf/api/customizer/parameter/UDFParameters.java
index 9b9b6640f0..31c8f1fb09 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/api/customizer/parameter/UDFParameters.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/api/customizer/parameter/UDFParameters.java
@@ -21,15 +21,10 @@ package org.apache.iotdb.db.query.udf.api.customizer.parameter;
 
 import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.mpp.plan.analyze.TypeProvider;
-import org.apache.iotdb.db.query.expression.Expression;
-import org.apache.iotdb.db.query.expression.multi.FunctionExpression;
 import org.apache.iotdb.db.query.udf.api.UDTF;
 import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -47,40 +42,28 @@ import java.util.Map;
  */
 public class UDFParameters {
 
-  private final List<Expression> expressions;
-  private final List<PartialPath> paths;
+  private final List<String> childExpressions;
+  private final List<PartialPath> maybeTimeSeriesPaths;
+  private final List<TSDataType> childExpressionDataTypes;
   private final Map<String, String> attributes;
-  private final List<TSDataType> dataTypes;
 
   public UDFParameters(
-      FunctionExpression functionExpression, Map<Expression, TSDataType> expressionDataTypeMap)
-      throws QueryProcessException {
-    expressions = functionExpression.getExpressions();
-    paths = functionExpression.getPaths();
-    attributes = functionExpression.getFunctionAttributes();
-    dataTypes = new ArrayList<>();
-    for (Expression expression : expressions) {
-      dataTypes.add(expressionDataTypeMap.get(expression));
-    }
+      List<String> childExpressions,
+      List<PartialPath> maybeTimeSeriesPaths,
+      List<TSDataType> childExpressionDataTypes,
+      Map<String, String> attributes) {
+    this.childExpressions = childExpressions;
+    this.maybeTimeSeriesPaths = maybeTimeSeriesPaths;
+    this.childExpressionDataTypes = childExpressionDataTypes;
+    this.attributes = attributes;
   }
 
-  public UDFParameters(FunctionExpression functionExpression, TypeProvider typeProvider)
-      throws QueryProcessException {
-    expressions = functionExpression.getExpressions();
-    paths = functionExpression.getPaths();
-    attributes = functionExpression.getFunctionAttributes();
-    dataTypes = new ArrayList<>();
-    for (Expression expression : expressions) {
-      dataTypes.add(typeProvider.getType(expression.toString()));
-    }
-  }
-
-  public List<Expression> getExpressions() {
-    return expressions;
+  public List<String> getChildExpressions() {
+    return childExpressions;
   }
 
   public List<PartialPath> getPaths() {
-    return paths;
+    return maybeTimeSeriesPaths;
   }
 
   public Map<String, String> getAttributes() {
@@ -88,15 +71,15 @@ public class UDFParameters {
   }
 
   public List<TSDataType> getDataTypes() throws MetadataException {
-    return dataTypes;
+    return childExpressionDataTypes;
   }
 
   public PartialPath getPath(int index) {
-    return paths.get(index);
+    return maybeTimeSeriesPaths.get(index);
   }
 
   public TSDataType getDataType(int index) throws MetadataException {
-    return dataTypes.get(index);
+    return childExpressionDataTypes.get(index);
   }
 
   public boolean hasAttribute(String attributeKey) {
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/api/customizer/strategy/AccessStrategy.java b/server/src/main/java/org/apache/iotdb/db/query/udf/api/customizer/strategy/AccessStrategy.java
index e86f1340f3..b3f946dabb 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/api/customizer/strategy/AccessStrategy.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/api/customizer/strategy/AccessStrategy.java
@@ -31,19 +31,13 @@ public interface AccessStrategy {
 
   enum AccessStrategyType {
 
-    /**
-     * @see RowByRowAccessStrategy
-     */
+    /** @see RowByRowAccessStrategy */
     ROW_BY_ROW,
 
-    /**
-     * @see SlidingTimeWindowAccessStrategy
-     */
+    /** @see SlidingTimeWindowAccessStrategy */
     SLIDING_TIME_WINDOW,
 
-    /**
-     * @see SlidingSizeWindowAccessStrategy
-     */
+    /** @see SlidingSizeWindowAccessStrategy */
     SLIDING_SIZE_WINDOW
   }
 
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/api/customizer/strategy/SlidingTimeWindowAccessStrategy.java b/server/src/main/java/org/apache/iotdb/db/query/udf/api/customizer/strategy/SlidingTimeWindowAccessStrategy.java
index e81aa21a88..5bb8b0c87a 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/api/customizer/strategy/SlidingTimeWindowAccessStrategy.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/api/customizer/strategy/SlidingTimeWindowAccessStrategy.java
@@ -19,7 +19,6 @@
 
 package org.apache.iotdb.db.query.udf.api.customizer.strategy;
 
-import org.apache.iotdb.db.qp.utils.DatetimeUtils;
 import org.apache.iotdb.db.query.udf.api.UDTF;
 import org.apache.iotdb.db.query.udf.api.access.RowWindow;
 import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
@@ -61,7 +60,7 @@ import java.time.ZoneId;
  *       parameters.getLong(0),       // display window begin
  *       parameters.getLong(10000))); // display window end
  * }</pre>
- * <p>Style 2:
+ * <p>Style 2 (deprecated since v0.14):
  * <pre>{@code
  * @Override
  * public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations) {
@@ -77,21 +76,16 @@ import java.time.ZoneId;
  */
 public class SlidingTimeWindowAccessStrategy implements AccessStrategy {
 
-  private final boolean inputInString;
-
-  private String timeIntervalString;
-  private String slidingStepString;
-  private String displayWindowBeginString;
-  private String displayWindowEndString;
-
-  private long timeInterval;
-  private long slidingStep;
-  private long displayWindowBegin;
-  private long displayWindowEnd;
+  private final long timeInterval;
+  private final long slidingStep;
+  private final long displayWindowBegin;
+  private final long displayWindowEnd;
 
   private ZoneId zoneId;
 
   /**
+   * Deprecated since v0.14.
+   *
    * @param timeIntervalString time interval in string. examples: 12d8m9ns, 1y1mo, etc. supported
    *     units: y, mo, w, d, h, m, s, ms, us, ns.
    * @param slidingStepString sliding step in string. examples: 12d8m9ns, 1y1mo, etc. supported
@@ -100,49 +94,48 @@ public class SlidingTimeWindowAccessStrategy implements AccessStrategy {
    *     2011-12-03T10:15:30+01:00.
    * @param displayWindowEndString display window end in string. format: 2011-12-03T10:15:30 or
    *     2011-12-03T10:15:30+01:00.
-   * @see DatetimeUtils.DurationUnit
+   * @throws UnsupportedOperationException deprecated since v0.14
    */
+  @Deprecated
   public SlidingTimeWindowAccessStrategy(
       String timeIntervalString,
       String slidingStepString,
       String displayWindowBeginString,
       String displayWindowEndString) {
-    inputInString = true;
-    this.timeIntervalString = timeIntervalString;
-    this.slidingStepString = slidingStepString;
-    this.displayWindowBeginString = displayWindowBeginString;
-    this.displayWindowEndString = displayWindowEndString;
+    throw new UnsupportedOperationException("The method is deprecated since v0.14.");
   }
 
   /**
-   * Display window begin will be set to the same as the minimum timestamp of the query result set,
-   * and display window end will be set to the same as the maximum timestamp of the query result
-   * set.
+   * Deprecated since v0.14.
+   *
+   * <p>Display window begin will be set to the same as the minimum timestamp of the query result
+   * set, and display window end will be set to the same as the maximum timestamp of the query
+   * result set.
    *
    * @param timeIntervalString time interval in string. examples: 12d8m9ns, 1y1mo, etc. supported
    *     units: y, mo, w, d, h, m, s, ms, us, ns.
    * @param slidingStepString sliding step in string. examples: 12d8m9ns, 1y1mo, etc. supported
    *     units: y, mo, w, d, h, m, s, ms, us, ns.
-   * @see DatetimeUtils.DurationUnit
+   * @throws UnsupportedOperationException deprecated since v0.14
    */
+  @Deprecated
   public SlidingTimeWindowAccessStrategy(String timeIntervalString, String slidingStepString) {
-    inputInString = true;
-    this.timeIntervalString = timeIntervalString;
-    this.slidingStepString = slidingStepString;
+    throw new UnsupportedOperationException("The method is deprecated since v0.14.");
   }
 
   /**
-   * Sliding step will be set to the same as the time interval, display window begin will be set to
-   * the same as the minimum timestamp of the query result set, and display window end will be set
-   * to the same as the maximum timestamp of the query result set.
+   * Deprecated since v0.14.
+   *
+   * <p>Sliding step will be set to the same as the time interval, display window begin will be set
+   * to the same as the minimum timestamp of the query result set, and display window end will be
+   * set to the same as the maximum timestamp of the query result set.
    *
    * @param timeIntervalString time interval in string. examples: 12d8m9ns, 1y1mo, etc. supported
    *     units: y, mo, w, d, h, m, s, ms, us, ns.
-   * @see DatetimeUtils.DurationUnit
+   * @throws UnsupportedOperationException deprecated since v0.14
    */
   public SlidingTimeWindowAccessStrategy(String timeIntervalString) {
-    inputInString = true;
-    this.timeIntervalString = timeIntervalString;
+    throw new UnsupportedOperationException("The method is deprecated since v0.14.");
   }
 
   /**
@@ -153,7 +146,6 @@ public class SlidingTimeWindowAccessStrategy implements AccessStrategy {
    */
   public SlidingTimeWindowAccessStrategy(
       long timeInterval, long slidingStep, long displayWindowBegin, long displayWindowEnd) {
-    inputInString = false;
     this.timeInterval = timeInterval;
     this.slidingStep = slidingStep;
     this.displayWindowBegin = displayWindowBegin;
@@ -169,7 +161,6 @@ public class SlidingTimeWindowAccessStrategy implements AccessStrategy {
    * @param slidingStep 0 < slidingStep
    */
   public SlidingTimeWindowAccessStrategy(long timeInterval, long slidingStep) {
-    inputInString = false;
     this.timeInterval = timeInterval;
     this.slidingStep = slidingStep;
     this.displayWindowBegin = Long.MIN_VALUE;
@@ -184,7 +175,6 @@ public class SlidingTimeWindowAccessStrategy implements AccessStrategy {
    * @param timeInterval 0 < timeInterval
    */
   public SlidingTimeWindowAccessStrategy(long timeInterval) {
-    inputInString = false;
     this.timeInterval = timeInterval;
     this.slidingStep = timeInterval;
     this.displayWindowBegin = Long.MIN_VALUE;
@@ -193,10 +183,6 @@ public class SlidingTimeWindowAccessStrategy implements AccessStrategy {
 
   @Override
   public void check() {
-    if (inputInString) {
-      parseStringParameters();
-    }
-
     if (timeInterval <= 0) {
       throw new RuntimeException(
           String.format("Parameter timeInterval(%d) should be positive.", timeInterval));
@@ -241,20 +227,4 @@ public class SlidingTimeWindowAccessStrategy implements AccessStrategy {
   public AccessStrategyType getAccessStrategyType() {
     return AccessStrategyType.SLIDING_TIME_WINDOW;
   }
-
-  private void parseStringParameters() {
-    timeInterval = DatetimeUtils.convertDurationStrToLong(timeIntervalString);
-    slidingStep =
-        slidingStepString == null
-            ? timeInterval
-            : DatetimeUtils.convertDurationStrToLong(slidingStepString);
-    displayWindowBegin =
-        displayWindowBeginString == null
-            ? Long.MIN_VALUE
-            : DatetimeUtils.convertDatetimeStrToLong(displayWindowBeginString, zoneId);
-    displayWindowEnd =
-        displayWindowEndString == null
-            ? Long.MAX_VALUE
-            : DatetimeUtils.convertDatetimeStrToLong(displayWindowEndString, zoneId);
-  }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/core/executor/UDTFExecutor.java b/server/src/main/java/org/apache/iotdb/db/query/udf/core/executor/UDTFExecutor.java
index b8f697f6b7..a811cd0ae1 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/core/executor/UDTFExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/core/executor/UDTFExecutor.java
@@ -19,10 +19,7 @@
 
 package org.apache.iotdb.db.query.udf.core.executor;
 
-import org.apache.iotdb.db.exception.query.QueryProcessException;
-import org.apache.iotdb.db.mpp.plan.analyze.TypeProvider;
-import org.apache.iotdb.db.query.expression.Expression;
-import org.apache.iotdb.db.query.expression.multi.FunctionExpression;
+import org.apache.iotdb.commons.path.PartialPath;
 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.access.RowWindow;
@@ -37,57 +34,36 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.time.ZoneId;
+import java.util.List;
 import java.util.Map;
 
 public class UDTFExecutor {
 
   private static final Logger LOGGER = LoggerFactory.getLogger(UDTFExecutor.class);
 
-  protected final FunctionExpression expression;
+  protected final String functionName;
   protected final UDTFConfigurations configurations;
 
   protected UDTF udtf;
   protected ElasticSerializableTVList collector;
 
-  public UDTFExecutor(FunctionExpression expression, ZoneId zoneId) {
-    this.expression = expression;
+  public UDTFExecutor(String functionName, ZoneId zoneId) {
+    this.functionName = functionName;
     configurations = new UDTFConfigurations(zoneId);
   }
 
-  public void beforeStart(long queryId, float collectorMemoryBudgetInMB, TypeProvider typeProvider)
-      throws QueryProcessException {
-    udtf = (UDTF) UDFRegistrationService.getInstance().reflect(expression);
-
-    UDFParameters parameters = new UDFParameters(expression, typeProvider);
-
-    try {
-      udtf.validate(new UDFParameterValidator(parameters));
-    } catch (Exception e) {
-      onError("validate(UDFParameterValidator)", e);
-    }
-
-    try {
-      udtf.beforeStart(parameters, configurations);
-    } catch (Exception e) {
-      onError("beforeStart(UDFParameters, UDTFConfigurations)", e);
-    }
-    configurations.check();
-
-    collector =
-        ElasticSerializableTVList.newElasticSerializableTVList(
-            configurations.getOutputDataType(), queryId, collectorMemoryBudgetInMB, 1);
-  }
-
-  // TODO: remove it after MPP finished
-  @Deprecated
   public void beforeStart(
       long queryId,
       float collectorMemoryBudgetInMB,
-      Map<Expression, TSDataType> expressionDataTypeMap)
-      throws QueryProcessException {
-    udtf = (UDTF) UDFRegistrationService.getInstance().reflect(expression);
+      List<String> childExpressions,
+      List<PartialPath> maybeTimeSeriesPaths,
+      List<TSDataType> childExpressionDataTypes,
+      Map<String, String> attributes) {
+    udtf = (UDTF) UDFRegistrationService.getInstance().reflect(functionName);
 
-    UDFParameters parameters = new UDFParameters(expression, expressionDataTypeMap);
+    final UDFParameters parameters =
+        new UDFParameters(
+            childExpressions, maybeTimeSeriesPaths, childExpressionDataTypes, attributes);
 
     try {
       udtf.validate(new UDFParameterValidator(parameters));
@@ -107,7 +83,7 @@ public class UDTFExecutor {
             configurations.getOutputDataType(), queryId, collectorMemoryBudgetInMB, 1);
   }
 
-  public void execute(Row row, boolean isCurrentRowNull) throws QueryProcessException {
+  public void execute(Row row, boolean isCurrentRowNull) {
     try {
       if (isCurrentRowNull) {
         // A null row will never trigger any UDF computing
@@ -120,7 +96,7 @@ public class UDTFExecutor {
     }
   }
 
-  public void execute(RowWindow rowWindow) throws QueryProcessException {
+  public void execute(RowWindow rowWindow) {
     try {
       udtf.transform(rowWindow, collector);
     } catch (Exception e) {
@@ -128,7 +104,7 @@ public class UDTFExecutor {
     }
   }
 
-  public void terminate() throws QueryProcessException {
+  public void terminate() {
     try {
       udtf.terminate(collector);
     } catch (Exception e) {
@@ -142,18 +118,14 @@ public class UDTFExecutor {
     }
   }
 
-  private void onError(String methodName, Exception e) throws QueryProcessException {
+  private void onError(String methodName, Exception e) {
     LOGGER.warn("Error occurred during executing UDTF", e);
-    throw new QueryProcessException(
+    throw new RuntimeException(
         String.format(
                 "Error occurred during executing UDTF#%s: %s", methodName, System.lineSeparator())
             + e);
   }
 
-  public FunctionExpression getExpression() {
-    return expression;
-  }
-
   public UDTFConfigurations getConfigurations() {
     return configurations;
   }
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/core/executor/UDTFTypeInferrer.java b/server/src/main/java/org/apache/iotdb/db/query/udf/core/executor/UDTFTypeInferrer.java
index ca7233906a..d089438384 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/core/executor/UDTFTypeInferrer.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/core/executor/UDTFTypeInferrer.java
@@ -19,9 +19,8 @@
 
 package org.apache.iotdb.db.query.udf.core.executor;
 
+import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.db.exception.sql.SemanticException;
-import org.apache.iotdb.db.mpp.plan.analyze.TypeProvider;
-import org.apache.iotdb.db.query.expression.multi.FunctionExpression;
 import org.apache.iotdb.db.query.udf.api.UDTF;
 import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
 import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
@@ -33,22 +32,30 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.time.ZoneId;
+import java.util.List;
+import java.util.Map;
 
 public class UDTFTypeInferrer {
 
   private static final Logger LOGGER = LoggerFactory.getLogger(UDTFTypeInferrer.class);
 
-  protected final FunctionExpression expression;
+  protected final String functionName;
 
-  public UDTFTypeInferrer(FunctionExpression expression) {
-    this.expression = expression;
+  public UDTFTypeInferrer(String functionName) {
+    this.functionName = functionName;
   }
 
-  public TSDataType inferOutputType(TypeProvider typeProvider) {
+  public TSDataType inferOutputType(
+      List<String> childExpressions,
+      List<PartialPath> maybeTimeSeriesPaths,
+      List<TSDataType> childExpressionDataTypes,
+      Map<String, String> attributes) {
     try {
-      UDTF udtf = (UDTF) UDFRegistrationService.getInstance().reflect(expression);
+      UDTF udtf = (UDTF) UDFRegistrationService.getInstance().reflect(functionName);
 
-      UDFParameters parameters = new UDFParameters(expression, typeProvider);
+      UDFParameters parameters =
+          new UDFParameters(
+              childExpressions, maybeTimeSeriesPaths, childExpressionDataTypes, attributes);
       udtf.validate(new UDFParameterValidator(parameters));
 
       // use ZoneId.systemDefault() because UDF's data type is ZoneId independent
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/SingleInputColumnSingleReferenceIntermediateLayer.java b/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/SingleInputColumnSingleReferenceIntermediateLayer.java
index 29549ccdd0..6d151e937b 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/SingleInputColumnSingleReferenceIntermediateLayer.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/core/layer/SingleInputColumnSingleReferenceIntermediateLayer.java
@@ -113,8 +113,7 @@ public class SingleInputColumnSingleReferenceIntermediateLayer extends Intermedi
 
   @Override
   protected LayerRowWindowReader constructRowSlidingSizeWindowReader(
-      SlidingSizeWindowAccessStrategy strategy, float memoryBudgetInMB)
-      throws QueryProcessException {
+      SlidingSizeWindowAccessStrategy strategy, float memoryBudgetInMB) {
 
     return new LayerRowWindowReader() {
 
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/datastructure/tv/ElasticSerializableBinaryTVList.java b/server/src/main/java/org/apache/iotdb/db/query/udf/datastructure/tv/ElasticSerializableBinaryTVList.java
index 687057e274..7ed0737df0 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/datastructure/tv/ElasticSerializableBinaryTVList.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/datastructure/tv/ElasticSerializableBinaryTVList.java
@@ -19,7 +19,6 @@
 
 package org.apache.iotdb.db.query.udf.datastructure.tv;
 
-import org.apache.iotdb.db.exception.query.QueryProcessException;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.utils.Binary;
 
@@ -36,8 +35,7 @@ public class ElasticSerializableBinaryTVList extends ElasticSerializableTVList {
   protected long totalByteArrayLengthLimit;
   protected long totalByteArrayLength;
 
-  public ElasticSerializableBinaryTVList(long queryId, float memoryLimitInMB, int cacheSize)
-      throws QueryProcessException {
+  public ElasticSerializableBinaryTVList(long queryId, float memoryLimitInMB, int cacheSize) {
     super(TSDataType.TEXT, queryId, memoryLimitInMB, cacheSize);
     byteArrayLengthForMemoryControl = INITIAL_BYTE_ARRAY_LENGTH_FOR_MEMORY_CONTROL;
     totalByteArrayLengthLimit = 0;
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/datastructure/tv/ElasticSerializableTVList.java b/server/src/main/java/org/apache/iotdb/db/query/udf/datastructure/tv/ElasticSerializableTVList.java
index 9e13e6333f..cec4cf0cc6 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/datastructure/tv/ElasticSerializableTVList.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/datastructure/tv/ElasticSerializableTVList.java
@@ -36,12 +36,10 @@ import java.util.List;
 public class ElasticSerializableTVList implements PointCollector {
 
   public static ElasticSerializableTVList newElasticSerializableTVList(
-      TSDataType dataType, long queryId, float memoryLimitInMB, int cacheSize)
-      throws QueryProcessException {
-    if (dataType.equals(TSDataType.TEXT)) {
-      return new ElasticSerializableBinaryTVList(queryId, memoryLimitInMB, cacheSize);
-    }
-    return new ElasticSerializableTVList(dataType, queryId, memoryLimitInMB, cacheSize);
+      TSDataType dataType, long queryId, float memoryLimitInMB, int cacheSize) {
+    return dataType.equals(TSDataType.TEXT)
+        ? new ElasticSerializableBinaryTVList(queryId, memoryLimitInMB, cacheSize)
+        : new ElasticSerializableTVList(dataType, queryId, memoryLimitInMB, cacheSize);
   }
 
   protected TSDataType dataType;
@@ -62,8 +60,7 @@ public class ElasticSerializableTVList implements PointCollector {
   protected int evictionUpperBound;
 
   protected ElasticSerializableTVList(
-      TSDataType dataType, long queryId, float memoryLimitInMB, int cacheSize)
-      throws QueryProcessException {
+      TSDataType dataType, long queryId, float memoryLimitInMB, int cacheSize) {
     this.dataType = dataType;
     this.queryId = queryId;
     this.memoryLimitInMB = memoryLimitInMB;
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/datastructure/tv/SerializableTVList.java b/server/src/main/java/org/apache/iotdb/db/query/udf/datastructure/tv/SerializableTVList.java
index edbee1c376..f595043e5b 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/datastructure/tv/SerializableTVList.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/datastructure/tv/SerializableTVList.java
@@ -19,7 +19,6 @@
 
 package org.apache.iotdb.db.query.udf.datastructure.tv;
 
-import org.apache.iotdb.db.exception.query.QueryProcessException;
 import org.apache.iotdb.db.query.udf.datastructure.SerializableList;
 import org.apache.iotdb.tsfile.exception.write.UnSupportedDataTypeException;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
@@ -47,8 +46,7 @@ public abstract class SerializableTVList extends BatchData implements Serializab
     }
   }
 
-  protected static int calculateCapacity(TSDataType dataType, float memoryLimitInMB)
-      throws QueryProcessException {
+  protected static int calculateCapacity(TSDataType dataType, float memoryLimitInMB) {
     int size;
     switch (dataType) {
       case INT32:
@@ -76,7 +74,7 @@ public abstract class SerializableTVList extends BatchData implements Serializab
     }
 
     if (size <= 0) {
-      throw new QueryProcessException("Memory is not enough for current query.");
+      throw new RuntimeException("Memory is not enough for current query.");
     }
     return size;
   }
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/service/UDFClassLoaderManager.java b/server/src/main/java/org/apache/iotdb/db/query/udf/service/UDFClassLoaderManager.java
index 2af5764747..99cf877d3e 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/service/UDFClassLoaderManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/service/UDFClassLoaderManager.java
@@ -46,9 +46,8 @@ public class UDFClassLoaderManager implements IService {
   /**
    * activeClassLoader is used to load all classes under libRoot. libRoot may be updated before the
    * user executes CREATE FUNCTION or after the user executes DROP FUNCTION. Therefore, we need to
-   * continuously maintain the activeClassLoader so that the classes it loads are always up to date.
+   * continuously maintain the activeClassLoader so that the classes it loads are always up-to-date.
    */
-  @SuppressWarnings("squid:S3077")
   private volatile UDFClassLoader activeClassLoader;
 
   UDFClassLoaderManager() {
diff --git a/server/src/main/java/org/apache/iotdb/db/query/udf/service/UDFRegistrationService.java b/server/src/main/java/org/apache/iotdb/db/query/udf/service/UDFRegistrationService.java
index af451f5e38..8f90da5c9d 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/udf/service/UDFRegistrationService.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/udf/service/UDFRegistrationService.java
@@ -26,9 +26,7 @@ import org.apache.iotdb.commons.service.ServiceType;
 import org.apache.iotdb.commons.utils.TestOnly;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.exception.UDFRegistrationException;
-import org.apache.iotdb.db.exception.query.QueryProcessException;
 import org.apache.iotdb.db.qp.constant.SQLConstant;
-import org.apache.iotdb.db.query.expression.multi.FunctionExpression;
 import org.apache.iotdb.db.query.udf.api.UDF;
 import org.apache.iotdb.db.query.udf.builtin.BuiltinFunction;
 import org.apache.iotdb.tsfile.fileSystem.FSFactoryProducer;
@@ -239,8 +237,8 @@ public class UDFRegistrationService implements IService {
     }
   }
 
-  public UDF reflect(FunctionExpression expression) throws QueryProcessException {
-    String functionName = expression.getFunctionName().toUpperCase();
+  public UDF reflect(String functionName) {
+    functionName = functionName.toUpperCase();
     UDFRegistrationInformation information = registrationInformation.get(functionName);
     if (information == null) {
       String errorMessage =
@@ -248,7 +246,7 @@ public class UDFRegistrationService implements IService {
               "Failed to reflect UDF instance, because UDF %s has not been registered.",
               functionName);
       logger.warn(errorMessage);
-      throw new QueryProcessException(errorMessage);
+      throw new RuntimeException(errorMessage);
     }
 
     if (!information.isBuiltin()) {
@@ -267,7 +265,7 @@ public class UDFRegistrationService implements IService {
               "Failed to reflect UDF %s(%s) instance, because %s",
               functionName, information.getClassName(), e);
       logger.warn(errorMessage);
-      throw new QueryProcessException(errorMessage);
+      throw new RuntimeException(errorMessage);
     }
   }
 
diff --git a/server/src/main/java/org/apache/iotdb/db/tools/watermark/WatermarkDetector.java b/server/src/main/java/org/apache/iotdb/db/tools/watermark/WatermarkDetector.java
index 54b0a0bbf6..45f9e35a6f 100644
--- a/server/src/main/java/org/apache/iotdb/db/tools/watermark/WatermarkDetector.java
+++ b/server/src/main/java/org/apache/iotdb/db/tools/watermark/WatermarkDetector.java
@@ -68,7 +68,7 @@ public class WatermarkDetector {
         dataType);
   }
 
-  @SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity warning
+  // Suppress high Cognitive Complexity warning
   public static boolean isWatermarked(
       String filePath,
       String secretKey,
@@ -171,12 +171,7 @@ public class WatermarkDetector {
     try {
       timestamp = Long.parseLong(str);
     } catch (NumberFormatException e) {
-      try {
-        ZoneId zoneId = ZoneId.systemDefault();
-        timestamp = DatetimeUtils.convertDatetimeStrToLong(str, zoneId);
-      } catch (LogicalOperatorException e1) {
-        throw new LogicalOperatorException("The format of timestamp is not unexpected.");
-      }
+      timestamp = DatetimeUtils.convertDatetimeStrToLong(str, ZoneId.systemDefault());
     }
     return timestamp;
   }
diff --git a/server/src/test/java/org/apache/iotdb/db/query/udf/datastructure/ElasticSerializableTVListTest.java b/server/src/test/java/org/apache/iotdb/db/query/udf/datastructure/ElasticSerializableTVListTest.java
index 865c270266..b8fa26fac3 100644
--- a/server/src/test/java/org/apache/iotdb/db/query/udf/datastructure/ElasticSerializableTVListTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/query/udf/datastructure/ElasticSerializableTVListTest.java
@@ -92,13 +92,9 @@ public class ElasticSerializableTVListTest extends SerializableListTest {
   }
 
   private void initESTVList(TSDataType dataType) {
-    try {
-      tvList =
-          ElasticSerializableTVList.newElasticSerializableTVList(
-              dataType, QUERY_ID, MEMORY_USAGE_LIMIT_IN_MB, CACHE_SIZE);
-    } catch (QueryProcessException e) {
-      fail(e.toString());
-    }
+    tvList =
+        ElasticSerializableTVList.newElasticSerializableTVList(
+            dataType, QUERY_ID, MEMORY_USAGE_LIMIT_IN_MB, CACHE_SIZE);
     assertEquals(0, tvList.size());
   }
 
@@ -160,7 +156,7 @@ public class ElasticSerializableTVListTest extends SerializableListTest {
           }
           break;
       }
-    } catch (IOException | QueryProcessException e) {
+    } catch (IOException e) {
       fail(e.toString());
     }
     assertEquals(ITERATION_TIMES, tvList.size());