You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/10/24 03:09:10 UTC

[GitHub] [flink] wuchong commented on a change in pull request #9916: [FLINK-14408][Table-Planner]UDF's open method is invoked to initialize when sql is optimized in oldPlanner

wuchong commented on a change in pull request #9916: [FLINK-14408][Table-Planner]UDF's open method is invoked to initialize when sql is optimized in oldPlanner
URL: https://github.com/apache/flink/pull/9916#discussion_r338355369
 
 

 ##########
 File path: flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/codegen/ExpressionReducer.scala
 ##########
 @@ -164,3 +180,96 @@ class ExpressionReducer(config: TableConfig)
     }
   }
 }
+
+/**
+  * A [[ConstantFunctionContext]] allows to obtain user-defined configuration information set
+  * in [[TableConfig]].
+  *
+  * @param parameters User-defined configuration set in [[TableConfig]].
+  */
+class ConstantFunctionContext(parameters: Configuration) extends FunctionContext(null) {
+
+  override def getMetricGroup: MetricGroup = {
+    throw new UnsupportedOperationException("getMetricGroup is not supported when optimizing")
+  }
+
+  override def getCachedFile(name: String): File = {
+    throw new UnsupportedOperationException("getCachedFile is not supported when optimizing")
+  }
+
+  /**
+    * Gets the user-defined configuration value associated with the given key as a string.
+    *
+    * @param key          key pointing to the associated value
+    * @param defaultValue default value which is returned in case user-defined configuration
+    *                     value is null or there is no value associated with the given key
+    * @return (default) value associated with the given key
+    */
+  override def getJobParameter(key: String, defaultValue: String): String = {
+    parameters.getString(key, defaultValue)
+  }
+}
+
+/**
+  * A [[ConstantFunctionCodeGenerator]] used for constant expression code generator
+  * @param config configuration that determines runtime behavior
+  * @param nullableInput input(s) can be null.
+  * @param input1 type information about the first input of the Function
+  * @param functionContext functionContext that used for code generator
+  * @param parameters parameters that accessed by openFunction
+  */
+class ConstantFunctionCodeGenerator(config: TableConfig,
+                                    nullableInput: Boolean,
+                                    input1: TypeInformation[_ <: Any],
+                                    functionContext: FunctionContext,
+                                    parameters: String = null)
+  extends FunctionCodeGenerator(config, nullableInput, input1) {
+
+  override def addReusableFunction(function: UserDefinedFunction,
 
 Review comment:
   Codes of this method are duplicate with the super class. Could we use the similar way as blink planner? Add a `functionContextClass: Class[_ <: FunctionContext] = classOf[FunctionContext],` optional parameter. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services