xtern commented on code in PR #3666:
URL: https://github.com/apache/ignite-3/pull/3666#discussion_r1583224243


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/TableFunctionImpl.java:
##########
@@ -0,0 +1,200 @@
+/*
+ * 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.
+ */
+
+//CHECKSTYLE:OFF
+package org.apache.ignite.internal.sql.engine.exec.exp;
+
+import static java.util.Objects.requireNonNull;
+import static org.apache.calcite.util.ReflectUtil.isPublic;
+import static org.apache.calcite.util.ReflectUtil.isStatic;
+import static org.apache.calcite.util.Static.RESOURCE;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.calcite.adapter.enumerable.NullPolicy;
+import org.apache.calcite.linq4j.tree.Expression;
+import org.apache.calcite.linq4j.tree.Expressions;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.schema.QueryableTable;
+import org.apache.calcite.schema.ScannableTable;
+import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.schema.Table;
+import org.apache.calcite.schema.TableFunction;
+import org.apache.calcite.schema.impl.ReflectiveFunctionBase;
+import org.apache.calcite.util.BuiltInMethod;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/**
+ * Implementation of {@link org.apache.calcite.schema.TableFunction} based on a
+ * method.
+ */
+public class TableFunctionImpl extends ReflectiveFunctionBase
+        implements TableFunction, ImplementableFunction {
+    private final CallImplementor implementor;
+
+    /** Private constructor; use {@link #create}. */
+    private TableFunctionImpl(Method method, CallImplementor implementor) {
+        super(method);
+        this.implementor = implementor;
+    }
+
+    /** Creates a {@link org.apache.calcite.schema.impl.TableFunctionImpl} 
from a class, looking for an "eval"
+     * method. Returns null if there is no such method. */
+    public static @Nullable TableFunction create(Class<?> clazz) {

Review Comment:
   why do we need this method (and the following)?
   p.s. I see for "eval" but can't figure out what's not working :pensive: 



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/TableFunctionImpl.java:
##########
@@ -0,0 +1,200 @@
+/*
+ * 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.
+ */
+
+//CHECKSTYLE:OFF
+package org.apache.ignite.internal.sql.engine.exec.exp;
+
+import static java.util.Objects.requireNonNull;
+import static org.apache.calcite.util.ReflectUtil.isPublic;
+import static org.apache.calcite.util.ReflectUtil.isStatic;
+import static org.apache.calcite.util.Static.RESOURCE;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.calcite.adapter.enumerable.NullPolicy;
+import org.apache.calcite.linq4j.tree.Expression;
+import org.apache.calcite.linq4j.tree.Expressions;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.schema.QueryableTable;
+import org.apache.calcite.schema.ScannableTable;
+import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.schema.Table;
+import org.apache.calcite.schema.TableFunction;
+import org.apache.calcite.schema.impl.ReflectiveFunctionBase;
+import org.apache.calcite.util.BuiltInMethod;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/**
+ * Implementation of {@link org.apache.calcite.schema.TableFunction} based on a
+ * method.
+ */
+public class TableFunctionImpl extends ReflectiveFunctionBase
+        implements TableFunction, ImplementableFunction {
+    private final CallImplementor implementor;
+
+    /** Private constructor; use {@link #create}. */
+    private TableFunctionImpl(Method method, CallImplementor implementor) {
+        super(method);
+        this.implementor = implementor;
+    }
+
+    /** Creates a {@link org.apache.calcite.schema.impl.TableFunctionImpl} 
from a class, looking for an "eval"
+     * method. Returns null if there is no such method. */
+    public static @Nullable TableFunction create(Class<?> clazz) {
+        return create(clazz, "eval");
+    }
+
+    /** Creates a {@link org.apache.calcite.schema.impl.TableFunctionImpl} 
from a class, looking for a method
+     * with a given name. Returns null if there is no such method. */
+    public static @Nullable TableFunction create(Class<?> clazz, String 
methodName) {
+        final Method method = findMethod(clazz, methodName);
+        if (method == null) {
+            return null;
+        }
+        return create(method);
+    }
+
+    /**
+     * Finds a method in a given class by name.
+     *
+     * @param clazz class to search method in
+     * @param name name of the method to find
+     * @return the first method with matching name or null when no method found
+     */
+    static @Nullable Method findMethod(Class<?> clazz, String name) {

Review Comment:
   is it possible to use this method in RexToLixTranslator and remove the same 
method from RexToLixTranslator?
   or move it to some utility-class?



-- 
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