hanyuzheng7 commented on code in PR #22917:
URL: https://github.com/apache/flink/pull/22917#discussion_r1249015509


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/ArrayElementOutputTypeStrategy.java:
##########
@@ -1,47 +0,0 @@
-/*
- * 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.types.inference.strategies;
-
-import org.apache.flink.annotation.Internal;
-import org.apache.flink.table.functions.BuiltInFunctionDefinitions;
-import org.apache.flink.table.types.CollectionDataType;
-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}. */
-@Internal
-public class ArrayElementOutputTypeStrategy implements TypeStrategy {
-    @Override
-    public Optional<DataType> inferType(CallContext callContext) {
-        DataType inputDataType = callContext.getArgumentDataTypes().get(0);
-        if (inputDataType.getLogicalType().getTypeRoot() != 
LogicalTypeRoot.ARRAY) {
-            return Optional.empty();
-        }
-        final DataType elementDataType = ((CollectionDataType) 
inputDataType).getElementDataType();
-        if (inputDataType.getLogicalType().isNullable()) {

Review Comment:
   I think you cannot remove this class, because this class name is 
ArrayElementOutputTypeStrategy, you must to check whether the input is a Array. 
if other one use this strategy but their input strategy is not an array, this 
class can throw exception.



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/strategies/SpecificTypeStrategies.java:
##########
@@ -58,8 +58,12 @@ public final class SpecificTypeStrategies {
     /** See {@link ArrayTypeStrategy}. */
     public static final TypeStrategy ARRAY = new ArrayTypeStrategy();
 
-    /** See {@link ArrayElementOutputTypeStrategy}. */
-    public static final TypeStrategy ARRAY_ELEMENT = new 
ArrayElementOutputTypeStrategy();
+    /** Type strategy specific for array element. */
+    public static final TypeStrategy ARRAY_ELEMENT =
+            callContext ->
+                    Optional.of(

Review Comment:
   > @dawidwys The input will check whether it is array. If not, it will throw 
exception
   
   I don't think so, this strategy named ARRAY_ELEMENT. you must to check it's 
input is array first. you cannot guarantee that others check it is array in 
input 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to