dianfu commented on a change in pull request #9858: [FLINK-14208][python]
Optimize Python UDFs with parameters of constant values
URL: https://github.com/apache/flink/pull/9858#discussion_r332985650
##########
File path:
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/plan/nodes/CommonPythonCalc.scala
##########
@@ -27,18 +28,20 @@ import scala.collection.mutable
trait CommonPythonCalc {
+ private[flink] lazy val rexLiteralToPythonObject = {
+ val clazz =
Class.forName("org.apache.flink.api.common.python.PythonBridgeUtils")
+ clazz.getMethod("rexLiteralToPythonObject", classOf[Object],
classOf[SqlTypeName])
+ }
+
private[flink] def extractPythonScalarFunctionInfos(
rexCalls: Array[RexCall]): (Array[Int], Array[PythonFunctionInfo]) = {
// using LinkedHashMap to keep the insert order
val inputNodes = new mutable.LinkedHashMap[RexNode, Integer]()
val pythonFunctionInfos = rexCalls.map(createPythonScalarFunctionInfo(_,
inputNodes))
- val udfInputOffsets = inputNodes.toArray.map(_._1).map {
- case inputRef: RexInputRef => inputRef.getIndex
- case _: RexLiteral => throw new Exception(
- "Constants cannot be used as parameters of Python UDF for now. " +
- "It will be supported in FLINK-14208")
- }
+ val udfInputOffsets = inputNodes.toArray
+ .map(_._1).filter(_.isInstanceOf[RexInputRef])
Review comment:
Move `.filter(xxx)` to a new line?
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services