You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "zstan (via GitHub)" <gi...@apache.org> on 2024/04/26 05:31:20 UTC
[PR] IGNITE-20294 Sql. Using UDF as a place for system_range function [ignite-3]
zstan opened a new pull request, #3666:
URL: https://github.com/apache/ignite-3/pull/3666
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20294 Sql. Using UDF as a place for system_range function [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
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:
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20294 Sql. Using UDF as a place for system_range function [ignite-3]
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #3666:
URL: https://github.com/apache/ignite-3/pull/3666#discussion_r1580747676
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/sql/fun/SqlSystemRangeFunction.java:
##########
@@ -17,36 +17,49 @@
package org.apache.ignite.internal.sql.engine.sql.fun;
-import org.apache.calcite.sql.SqlFunction;
-import org.apache.calcite.sql.SqlFunctionCategory;
+import static org.apache.calcite.sql.type.InferTypes.ANY_NULLABLE;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.sql.SqlIdentifier;
import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.sql.SqlOperatorBinding;
-import org.apache.calcite.sql.SqlTableFunction;
+import org.apache.calcite.sql.parser.SqlParserPos;
import org.apache.calcite.sql.type.OperandTypes;
import org.apache.calcite.sql.type.ReturnTypes;
-import org.apache.calcite.sql.type.SqlReturnTypeInference;
+import org.apache.calcite.sql.type.SqlOperandMetadata;
import org.apache.calcite.sql.type.SqlTypeFamily;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.sql.validate.SqlMonotonicity;
+import org.apache.calcite.sql.validate.SqlUserDefinedTableFunction;
+import org.apache.ignite.internal.sql.engine.exec.exp.TableFunctionImpl;
/**
* Definition of the "SYSTEM_RANGE" builtin SQL function.
*/
-public class SqlSystemRangeFunction extends SqlFunction implements SqlTableFunction {
+public class SqlSystemRangeFunction extends SqlUserDefinedTableFunction {
/**
* Creates the SqlSystemRangeFunction.
*/
- SqlSystemRangeFunction() {
+ SqlSystemRangeFunction(Method method, String funcName) {
super(
- "SYSTEM_RANGE",
+ new SqlIdentifier(funcName, SqlParserPos.ZERO),
Review Comment:
What is a point of making a function name configurable, if this function can only used for a system range function?
##########
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
Review Comment:
Why this one is copied? How it differs from calcite's TableFunctionImpl?
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20294 Sql. Using UDF as a place for system_range function [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20294 Sql. Using UDF as a place for system_range function [ignite-3]
Posted by "zstan (via GitHub)" <gi...@apache.org>.
zstan closed pull request #3666: IGNITE-20294 Sql. Using UDF as a place for system_range function
URL: https://github.com/apache/ignite-3/pull/3666
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org