You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "hanyuzheng7 (via GitHub)" <gi...@apache.org> on 2023/06/30 20:41:17 UTC

[GitHub] [flink] hanyuzheng7 opened a new pull request, #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

hanyuzheng7 opened a new pull request, #22922:
URL: https://github.com/apache/flink/pull/22922

   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   *(For example: This pull request makes task deployment go through the blob server, rather than through RPC. That way we avoid re-transferring them on each deployment (during recovery).)*
   
   
   ## Brief change log
   
   *(for example:)*
     - *The TaskInfo is stored in the blob store on job creation time as a persistent artifact*
     - *Deployments RPC transmits only the blob storage reference*
     - *TaskManagers retrieve the TaskInfo from the blob cache*
   
   
   ## Verifying this change
   
   Please make sure both new and modified tests in this PR follows the conventions defined in our code quality guide: https://flink.apache.org/contributing/code-style-and-quality-common.html#testing
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (100MB)*
     - *Extended integration test for recovery after master (JobManager) failure*
     - *Added test that validates that TaskInfo is transferred only once across recoveries*
     - *Manually verified the change by running a 4 node cluster with 2 JobManagers and 4 TaskManagers, a stateful streaming program, and killing one JobManager and two TaskManagers during the execution, verifying that recovery happens correctly.*
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / no)
     - The serializers: (yes / no / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / no / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
     - The S3 file system connector: (yes / no / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251628168


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   Yes, we need it. In this situation -> SELECT ARRAY_MIN(), although we set argumentCount to one, but argumentDataTypes.size() == 0, if we do not check whether it is smaller than one, it will report out of boundary exception here. 
   `final DataType argumentType = argumentDataTypes.get(0); `
   
   This situation are very special. without inputting any argument, argumentCount cannot cover this situation. It seem treat without having any argument as an type input argument.
   
   But if the input arguments number is larger than one, argumentCount will handle this situation.
   
   https://github.com/apache/flink/pull/22922/files/30098f6ed81b8be7b41e7bf75adfcd495a2c6acf#r1251632875



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] dawidwys commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "dawidwys (via GitHub)" <gi...@apache.org>.
dawidwys commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251600663


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   why do we need that? That should be covered alrready by the `ArgumentCount`



##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/scalar/ArrayMinFunction.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.runtime.functions.scalar;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.data.ArrayData;
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.table.functions.FunctionContext;
+import org.apache.flink.table.functions.SpecializedFunction;
+import org.apache.flink.table.types.CollectionDataType;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.util.FlinkRuntimeException;
+
+import javax.annotation.Nullable;
+
+import java.lang.invoke.MethodHandle;
+
+import static org.apache.flink.table.api.Expressions.$;
+
+/** Implementation of {@link BuiltInFunctionDefinitions#ARRAY_MIN}. */
+@Internal
+public class ArrayMinFunction extends BuiltInScalarFunction {
+    private final ArrayData.ElementGetter elementGetter;
+    private final SpecializedFunction.ExpressionEvaluator compareEvaluator;
+    private transient MethodHandle compareHandle;
+
+    public ArrayMinFunction(SpecializedFunction.SpecializedContext context) {
+        super(BuiltInFunctionDefinitions.ARRAY_MIN, context);
+
+        final DataType dataType =
+                ((CollectionDataType) context.getCallContext().getArgumentDataTypes().get(0))
+                        .getElementDataType();
+        elementGetter = ArrayData.createElementGetter(dataType.getLogicalType());
+        compareEvaluator =
+                context.createEvaluator(
+                        $("element1").isLess($("element2")),
+                        DataTypes.BOOLEAN().notNull(),
+                        DataTypes.FIELD("element1", dataType.notNull().toInternal()),
+                        DataTypes.FIELD("element2", dataType.notNull().toInternal()));
+    }
+
+    @Override
+    public void open(FunctionContext context) throws Exception {
+        compareHandle = compareEvaluator.open(context);
+    }
+
+    public @Nullable Object eval(ArrayData array) {
+        try {
+            if (array == null || array.size() == 0) {
+                return null;
+            }
+
+            Object maxElement = null;
+            for (int i = 0; i < array.size(); i++) {
+                Object element = elementGetter.getElementOrNull(array, i);
+                if (element != null) {
+                    if (maxElement == null || (boolean) compareHandle.invoke(element, maxElement)) {

Review Comment:
   `minElement`?



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayElementOutputTypeStrategy.java:
##########
@@ -24,24 +24,19 @@
 import org.apache.flink.table.types.DataType;
 import org.apache.flink.table.types.inference.CallContext;
 import org.apache.flink.table.types.inference.TypeStrategy;
-import org.apache.flink.table.types.logical.LogicalTypeRoot;
 
 import java.util.Optional;
 
-/** Specific {@link TypeStrategy} for {@link BuiltInFunctionDefinitions#ARRAY_MAX}. */
+/**

Review Comment:
   Let's rebase that on top of https://github.com/apache/flink/pull/22917



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CollectionFunctionsITCase.java:
##########
@@ -723,6 +730,182 @@ private Stream<TestSetSpec> arrayMaxTestCases() {
                         .testSqlValidationError(
                                 "ARRAY_MAX(f12)",
                                 "SQL validation failed. Invalid function call:\n"
-                                        + "ARRAY_MAX(ARRAY<ARRAY<INT>>)"));
+                                        + "ARRAY_MAX(ARRAY<ARRAY<INT>>)")
+                        .testSqlValidationError(
+                                "ARRAY_MAX()", "No match found for function signature ARRAY_MAX()")
+                        .testSqlValidationError("ARRAY_MAX(ARRAY[])", "Require at least 1 argument")

Review Comment:
   Let's not test `ARRAY` ctor here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1253880382


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   I find use argumentTypeStrategy to achieve this strategy can solve this problem. We can use argumentTypeStrategy to achieve this strategy.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251628168


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   Yes, we need it. In this situation -> SELECT ARRAY_MIN(), although we set argumentCount to one, but argumentDataTypes.size() == 0, if we do not check whether it is smaller than one, it report out of boundary exception here. 
   `final DataType argumentType = argumentDataTypes.get(0); `
   
   This situation are very special. without inputting any argument, argumentCount cannot cover this situation.
   
   But if the input arguments number is larger than one, argumentCount will handle this situation.
   
   https://github.com/apache/flink/pull/22922/files/30098f6ed81b8be7b41e7bf75adfcd495a2c6acf#r1251632875



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on PR #22922:
URL: https://github.com/apache/flink/pull/22922#issuecomment-1622101928

   @flinkbot run azure


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251628168


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   Yes, we need it. In this situation -> SELECT ARRAY_MIN(), although we set argumentCount to one, but argumentDataTypes.size() == 0, if we do not check whether it is smaller than one, it will report out of boundary exception here. 
   `final DataType argumentType = argumentDataTypes.get(0); `
   
   This situation are very special. without inputting any argument, argumentCount cannot cover this situation.
   
   But if the input arguments number is larger than one, argumentCount will handle this situation.
   
   https://github.com/apache/flink/pull/22922/files/30098f6ed81b8be7b41e7bf75adfcd495a2c6acf#r1251632875



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251628168


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   Yes, we need it. In this situation -> SELECT ARRAY_MIN(), although we set argumentCount to one, but argumentDataTypes.size() == 0, if we do not check whether it is smaller than one, it report out of boundary exception.
   
   But if the input arguments number is larger than one, argumentCount will handle this situation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1252435731


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   I think we can use 
   ` if (argumentDataTypes.size() < 1) {
               return Optional.empty();
           }`
   to handle empty input situation temporary, because  Calcite's stack inference logic and the argument count check can work except empty argument input. Once the bug in the Calcite's stack inference logic and the argument count check solved, we can remove this if statement. This if statement will not cause any bugs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1252435539


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   @dawidwys Is this OK?
   I think we can use 
   ` if (argumentDataTypes.size() < 1) {
               return Optional.empty();
           }`
   first to handle empty input situation, because  Calcite's stack inference logic and the argument count check can work except empty argument input. Once the bug in the Calcite's stack inference logic and the argument count check solved, we can remove this if statement.
   https://github.com/apache/flink/pull/22922/files#r1252434610



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251628168


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   Yes, we need it. In this situation -> SELECT ARRAY_MIN(), although we set argumentCount to one, but argumentDataTypes.size() == 0, if we do not check whether it is smaller than one, it report out of boundary exception here
   `final DataType argumentType = argumentDataTypes.get(0); `
   
   But if the input arguments number is larger than one, argumentCount will handle this situation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251631378


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CollectionFunctionsITCase.java:
##########
@@ -723,6 +730,182 @@ private Stream<TestSetSpec> arrayMaxTestCases() {
                         .testSqlValidationError(
                                 "ARRAY_MAX(f12)",
                                 "SQL validation failed. Invalid function call:\n"
-                                        + "ARRAY_MAX(ARRAY<ARRAY<INT>>)"));
+                                        + "ARRAY_MAX(ARRAY<ARRAY<INT>>)")
+                        .testSqlValidationError(
+                                "ARRAY_MAX()", "No match found for function signature ARRAY_MAX()")
+                        .testSqlValidationError("ARRAY_MAX(ARRAY[])", "Require at least 1 argument")

Review Comment:
   ok



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251628168


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   Yes, we need it. In this situation -> SELECT ARRAY_MIN(), although we set argumentCount to one, but argumentDataTypes.size() == 0, if we do not check whether it is smaller than one, it will report out of boundary exception here. 
   `final DataType argumentType = argumentDataTypes.get(0); `
   
   This situation are very special. without inputting any argument, argumentCount cannot cover this situation. It seem treat without having any argument as a special input method.
   
   But if the input arguments number is larger than one, argumentCount will handle this situation.
   
   https://github.com/apache/flink/pull/22922/files/30098f6ed81b8be7b41e7bf75adfcd495a2c6acf#r1251632875



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on PR #22922:
URL: https://github.com/apache/flink/pull/22922#issuecomment-1621034276

   @flinkbot run azure


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1252434610


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +68,10 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (!TypeInferenceUtil.checkInputArgumentNumber(
+                argumentCount, argumentDataTypes.size(), throwOnFailure)) {
+            return callContext.fail(throwOnFailure, "the input argument number should be one");
+        }

Review Comment:
   is this ok?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1253880382


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   I find use argumentTypeStrategy to achieve this strategy can solve this problem. We can use argumentTypeStrategy to achieve this strategy. Because argumentTypeStrategy must have one input argument



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251628168


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   Yes, we need it. In this situation -> SELECT ARRAY_MIN(), although we set argumentCount to one, but argumentDataTypes.size() == 0, if we do not check whether it is smaller than one, it will report out of boundary exception here. 
   `final DataType argumentType = argumentDataTypes.get(0); `
   
   This situation is very special. without inputting any argument, argumentCount cannot cover this situation. It seem that treat without having any argument as a special input method.
   
   But if the input arguments number is larger than one, argumentCount will handle this situation.
   
   https://github.com/apache/flink/pull/22922/files/30098f6ed81b8be7b41e7bf75adfcd495a2c6acf#r1251632875



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1252435539


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   @dawidwys Is this OK?
   https://github.com/apache/flink/pull/22922/files#r1252434610



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   I think we can use 
   ` if (argumentDataTypes.size() < 1) {
               return Optional.empty();
           }`
   first to handle empty input situation, because  Calcite's stack inference logic and the argument count check can work except empty argument input. Once the bug in the Calcite's stack inference logic and the argument count check solved, we can remove this if statement.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1252435731


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   I think we can use 
   ` if (argumentDataTypes.size() < 1) {
               return Optional.empty();
           }`
   to handle empty input situation temporary, because  Calcite's stack inference logic and the argument count check can work except empty argument input. Once the bug in the Calcite's stack inference logic and the argument count check solved, we can remove this if statement.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on PR #22922:
URL: https://github.com/apache/flink/pull/22922#issuecomment-1622901153

   @flinkbot run azure


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251628168


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   Yes, we need it. In this situation -> SELECT ARRAY_MIN(), although we set argumentCount to one, but argumentDataTypes.size() == 0, if we do not check whether it is smaller than one, it will report out of boundary exception here. 
   `final DataType argumentType = argumentDataTypes.get(0); `
   
   This situation is very special. without inputting any argument, argumentCount cannot cover this situation. It seem treat without having any argument as a special input method.
   
   But if the input arguments number is larger than one, argumentCount will handle this situation.
   
   https://github.com/apache/flink/pull/22922/files/30098f6ed81b8be7b41e7bf75adfcd495a2c6acf#r1251632875



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1252105421


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   you mean I can add a static method at TypeInfereceUtil to do the argument count check?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] flinkbot commented on pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #22922:
URL: https://github.com/apache/flink/pull/22922#issuecomment-1615182489

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "86adecb4b4efea7984e8d04a5194c2d6b2defb47",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "86adecb4b4efea7984e8d04a5194c2d6b2defb47",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 86adecb4b4efea7984e8d04a5194c2d6b2defb47 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251628168


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   Yes, we need it. In this situation[ ](https://github.com/apache/flink/pull/22922/files/30098f6ed81b8be7b41e7bf75adfcd495a2c6acf#r1251632875)-> SELECT ARRAY_MIN(), although we set argumentCount to one, but argumentDataTypes.size() == 0, if we do not check whether it is smaller than one, it report out of boundary exception here
   `final DataType argumentType = argumentDataTypes.get(0); `
   
   But if the input arguments number is larger than one, argumentCount will handle this situation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251628168


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   Yes, we need it. In this situation -> SELECT ARRAY_MIN(), although we set argumentCount to one, but argumentDataTypes.size() == 0, if we do not check whether it is smaller than one, it report out of boundary exception here
   `final DataType argumentType = argumentDataTypes.get(0); `
   
   But if the input arguments number is larger than one, argumentCount will handle this situation.
   
   https://github.com/apache/flink/pull/22922/files/30098f6ed81b8be7b41e7bf75adfcd495a2c6acf#r1251632875



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] dawidwys commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "dawidwys (via GitHub)" <gi...@apache.org>.
dawidwys commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251694324


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   hmm.. in my opinion that should not be the case.
   
   I am afraid there is a bug in the Calcite's stack inference logic and the argument count check is not performed correctly. I think we should rather adapt https://github.com/apache/flink/blob/ab70dcfa19827febd2c3cdc5cb81e942caa5b2f0/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/inference/TypeInferenceOperandInference.java#L81 to perform the count range check. Similarly like https://github.com/apache/flink/blob/fbc086f2fd63dac4af3e104ba4011e864781139a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/TypeInferenceUtil.java#L303 does.
   
   I need to double check that with @twalthr 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-32256][table] Add built-in ARRAY_ MIN function. [flink]

Posted by "dawidwys (via GitHub)" <gi...@apache.org>.
dawidwys closed pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.
URL: https://github.com/apache/flink/pull/22922


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-32256][table] Add built-in ARRAY_ MIN function. [flink]

Posted by "dawidwys (via GitHub)" <gi...@apache.org>.
dawidwys commented on PR #22922:
URL: https://github.com/apache/flink/pull/22922#issuecomment-1888707479

   subsumed by #24071 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-32256][table] Add built-in ARRAY_ MIN function. [flink]

Posted by "dawidwys (via GitHub)" <gi...@apache.org>.
dawidwys commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1446262428


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   The change in `TypeInferenceOperandInference` has been implemented. @hanyuzheng7 Would you like to revert the changes around checking operand count? If not, I am happy to do that myself, we could merge the PR afterwards.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251628168


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   Yes, we need it. In this situation -> SELECT ARRAY_MIN(), although we set argumentCount to one, but argumentDataTypes.size() == 0, if we do not check whether it is smaller than one, it report out of boundary exception here. This situation are very special. without inputting any argument, argumentCount cannot cover this sitution.
   `final DataType argumentType = argumentDataTypes.get(0); `
   
   But if the input arguments number is larger than one, argumentCount will handle this situation.
   
   https://github.com/apache/flink/pull/22922/files/30098f6ed81b8be7b41e7bf75adfcd495a2c6acf#r1251632875



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   Yes, we need it. In this situation -> SELECT ARRAY_MIN(), although we set argumentCount to one, but argumentDataTypes.size() == 0, if we do not check whether it is smaller than one, it report out of boundary exception here. This situation are very special. without inputting any argument, argumentCount cannot cover this situation.
   `final DataType argumentType = argumentDataTypes.get(0); `
   
   But if the input arguments number is larger than one, argumentCount will handle this situation.
   
   https://github.com/apache/flink/pull/22922/files/30098f6ed81b8be7b41e7bf75adfcd495a2c6acf#r1251632875



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251630904


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayElementOutputTypeStrategy.java:
##########
@@ -24,24 +24,19 @@
 import org.apache.flink.table.types.DataType;
 import org.apache.flink.table.types.inference.CallContext;
 import org.apache.flink.table.types.inference.TypeStrategy;
-import org.apache.flink.table.types.logical.LogicalTypeRoot;
 
 import java.util.Optional;
 
-/** Specific {@link TypeStrategy} for {@link BuiltInFunctionDefinitions#ARRAY_MAX}. */
+/**

Review Comment:
   ok



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251632875


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/CollectionFunctionsITCase.java:
##########
@@ -723,6 +730,182 @@ private Stream<TestSetSpec> arrayMaxTestCases() {
                         .testSqlValidationError(
                                 "ARRAY_MAX(f12)",
                                 "SQL validation failed. Invalid function call:\n"
-                                        + "ARRAY_MAX(ARRAY<ARRAY<INT>>)"));
+                                        + "ARRAY_MAX(ARRAY<ARRAY<INT>>)")
+                        .testSqlValidationError(
+                                "ARRAY_MAX()", "No match found for function signature ARRAY_MAX()")

Review Comment:
   this situation



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1252105421


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   you mean I can add a static method at TypeInfereceUtil to do the argument count check?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251641100


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/scalar/ArrayMinFunction.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.runtime.functions.scalar;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.data.ArrayData;
+import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
+import org.apache.flink.table.functions.FunctionContext;
+import org.apache.flink.table.functions.SpecializedFunction;
+import org.apache.flink.table.types.CollectionDataType;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.util.FlinkRuntimeException;
+
+import javax.annotation.Nullable;
+
+import java.lang.invoke.MethodHandle;
+
+import static org.apache.flink.table.api.Expressions.$;
+
+/** Implementation of {@link BuiltInFunctionDefinitions#ARRAY_MIN}. */
+@Internal
+public class ArrayMinFunction extends BuiltInScalarFunction {
+    private final ArrayData.ElementGetter elementGetter;
+    private final SpecializedFunction.ExpressionEvaluator compareEvaluator;
+    private transient MethodHandle compareHandle;
+
+    public ArrayMinFunction(SpecializedFunction.SpecializedContext context) {
+        super(BuiltInFunctionDefinitions.ARRAY_MIN, context);
+
+        final DataType dataType =
+                ((CollectionDataType) context.getCallContext().getArgumentDataTypes().get(0))
+                        .getElementDataType();
+        elementGetter = ArrayData.createElementGetter(dataType.getLogicalType());
+        compareEvaluator =
+                context.createEvaluator(
+                        $("element1").isLess($("element2")),
+                        DataTypes.BOOLEAN().notNull(),
+                        DataTypes.FIELD("element1", dataType.notNull().toInternal()),
+                        DataTypes.FIELD("element2", dataType.notNull().toInternal()));
+    }
+
+    @Override
+    public void open(FunctionContext context) throws Exception {
+        compareHandle = compareEvaluator.open(context);
+    }
+
+    public @Nullable Object eval(ArrayData array) {
+        try {
+            if (array == null || array.size() == 0) {
+                return null;
+            }
+
+            Object maxElement = null;
+            for (int i = 0; i < array.size(); i++) {
+                Object element = elementGetter.getElementOrNull(array, i);
+                if (element != null) {
+                    if (maxElement == null || (boolean) compareHandle.invoke(element, maxElement)) {

Review Comment:
   yes, I will fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on a diff in pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on code in PR #22922:
URL: https://github.com/apache/flink/pull/22922#discussion_r1251628168


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayComparableElementTypeStrategy.java:
##########
@@ -67,6 +67,9 @@ public ArgumentCount getArgumentCount() {
     public Optional<List<DataType>> inferInputTypes(
             CallContext callContext, boolean throwOnFailure) {
         final List<DataType> argumentDataTypes = callContext.getArgumentDataTypes();
+        if (argumentDataTypes.size() < 1) {
+            return Optional.empty();
+        }

Review Comment:
   Yes, we need it. In this situation -> SELECT ARRAY_MIN(), although we set argumentCount to one, but argumentDataTypes.size() == 0, if we do not check whether it is smaller than one, it will report out of boundary exception here. 
   `final DataType argumentType = argumentDataTypes.get(0); `
   
   This situation is very special. without inputting any argument, argumentCount cannot cover this situation. It seem that treat without having any argument as a special input argument.
   
   But if the input arguments number is larger than one, argumentCount will handle this situation.
   
   https://github.com/apache/flink/pull/22922/files/30098f6ed81b8be7b41e7bf75adfcd495a2c6acf#r1251632875



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hanyuzheng7 commented on pull request #22922: [FLINK-32256][table] Add built-in ARRAY_ MIN function.

Posted by "hanyuzheng7 (via GitHub)" <gi...@apache.org>.
hanyuzheng7 commented on PR #22922:
URL: https://github.com/apache/flink/pull/22922#issuecomment-1615226953

   @flinkbot run azure


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org