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

chenyz pushed a commit to branch tvf_parameter
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/tvf_parameter by this push:
     new 9c7ae1b7bbe done
9c7ae1b7bbe is described below

commit 9c7ae1b7bbee9057b04ea72093feb08dca3620ff
Author: Chen YZ <[email protected]>
AuthorDate: Wed Apr 30 16:20:06 2025 +0800

    done
---
 .../specification/ParameterSpecification.java      | 10 ++++++---
 .../config/executor/ClusterConfigTaskExecutor.java |  2 +-
 .../relational/analyzer/StatementAnalyzer.java     | 25 +++++++++++++++++-----
 3 files changed, 28 insertions(+), 9 deletions(-)

diff --git 
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/relational/table/specification/ParameterSpecification.java
 
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/relational/table/specification/ParameterSpecification.java
index 180e3e6307e..e81292a6c94 100644
--- 
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/relational/table/specification/ParameterSpecification.java
+++ 
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/relational/table/specification/ParameterSpecification.java
@@ -37,9 +37,10 @@
 
 package org.apache.iotdb.udf.api.relational.table.specification;
 
-import java.util.Locale;
 import java.util.Optional;
 
+import static java.util.Locale.ENGLISH;
+
 /**
  * Abstract class to capture the three supported argument types for a table 
function: - Table
  * arguments - Descriptor arguments - SQL scalar arguments
@@ -56,8 +57,7 @@ public abstract class ParameterSpecification {
   private final Optional<Object> defaultValue;
 
   ParameterSpecification(String name, boolean required, Optional<Object> 
defaultValue) {
-    // name will be stored in upper case to avoid case sensitivity issues
-    this.name = name.toUpperCase(Locale.ENGLISH);
+    this.name = name;
     this.required = required;
     this.defaultValue = defaultValue;
     if (required && defaultValue.isPresent()) {
@@ -69,6 +69,10 @@ public abstract class ParameterSpecification {
     return name;
   }
 
+  public String getCanonicalName() {
+    return name.toUpperCase(ENGLISH);
+  }
+
   public boolean isRequired() {
     return required;
   }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
index 892a74a4319..56e36fbe0da 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
@@ -628,7 +628,7 @@ public class ClusterConfigTaskExecutor implements 
IConfigTaskExecutor {
             Set<String> argNames = new HashSet<>();
             for (ParameterSpecification specification :
                 tableFunction.getArgumentsSpecifications()) {
-              if (!argNames.add(specification.getName())) {
+              if (!argNames.add(specification.getName().toUpperCase())) {
                 future.setException(
                     new IoTDBException(
                         "Failed to create function '"
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
index fc7589a69c2..7ce04d79e11 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
@@ -4192,6 +4192,18 @@ public class StatementAnalyzer {
       return createAndAssignScope(node, scope, fields.build());
     }
 
+    private String castNameAsSpecification(Set<String> specifiedNames, String 
passedName) {
+      if (specifiedNames.contains(passedName)) {
+        return passedName;
+      }
+      for (String name : specifiedNames) {
+        if (name.equalsIgnoreCase(passedName)) {
+          return name;
+        }
+      }
+      return null;
+    }
+
     private ArgumentsAnalysis analyzeArguments(
         List<ParameterSpecification> parameterSpecifications,
         List<TableFunctionArgument> arguments,
@@ -4235,16 +4247,19 @@ public class StatementAnalyzer {
         Set<String> uniqueArgumentNames = new HashSet<>();
         for (TableFunctionArgument argument : arguments) {
           // it has been checked that all arguments have different names
-          String argumentName = argument.getName().get().getCanonicalValue();
+          String argumentName =
+              castNameAsSpecification(
+                  argumentSpecificationsByName.keySet(),
+                  argument.getName().get().getCanonicalValue());
+          if (argumentName == null) {
+            throw new SemanticException(
+                String.format("Unexpected argument name: %s", 
argument.getName().get().getValue()));
+          }
           if (!uniqueArgumentNames.add(argumentName)) {
             throw new SemanticException(String.format("Duplicate argument 
name: %s", argumentName));
           }
           ParameterSpecification parameterSpecification =
               argumentSpecificationsByName.remove(argumentName);
-          if (parameterSpecification == null) {
-            throw new SemanticException(
-                String.format("Unexpected argument name: %s", argumentName));
-          }
           ArgumentAnalysis argumentAnalysis =
               analyzeArgument(parameterSpecification, argument, scope);
           passedArguments.put(argumentName, argumentAnalysis.getArgument());

Reply via email to