flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [flink] dawidwys commented on a change in pull request #14378: [FLINK-20522][table] Make implementing a built-in function straightforward
Date Thu, 07 Jan 2021 11:26:43 GMT

dawidwys commented on a change in pull request #14378:
URL: https://github.com/apache/flink/pull/14378#discussion_r553270306

File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/SpecializedFunction.java
@@ -0,0 +1,73 @@
+ * 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.functions;
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.configuration.ReadableConfig;
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.catalog.DataTypeFactory;
+import org.apache.flink.table.types.inference.CallContext;
+ * A {@link FunctionDefinition} that can provide a runtime implementation (i.e. the function's
+ * that is specialized for the given call and session.
+ *
+ * <p>The planner tries to defer the specialization until shortly before code generation,
where the
+ * information given by a {@link FunctionDefinition} is not enough anymore and a subclass
+ * {@link UserDefinedFunction} is required for runtime.
+ *
+ * <p>This interface is useful when the runtime code should know about information
that is only available
+ * after planning (e.g. local session time zone or precision/scale of decimal return type).
+ *
+ * <p>A {@link UserDefinedFunction} that is registered in the API is implicitly specialized
but can
+ * also implement this interface to reconfigure itself before runtime.
+ */
+public interface SpecializedFunction extends FunctionDefinition {
+	/**
+	 * Provides a runtime implementation that is specialized for the given call and session.
+	 *
+	 * <p>The method must return an instance of {@link UserDefinedFunction} or throw a
{@link TableException}
+	 * if the given call is not supported. The returned instance must have the same {@link FunctionDefinition}
+	 * semantics but can have a different {@link #getTypeInference(DataTypeFactory)} implementation.

Review comment:
       Sorry, my example was wrong, in a respect that I did not use a literal and therefore
never ended up with `new NumberScalarFunction(true)`. Because of the example I assumed we
do not have such a check, but obviously we do. Again sorry for the confusion. Nice that we
have that check!
   Still it won't harm to have a slightly more prominent warning.

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.

For queries about this service, please contact Infrastructure at:

View raw message