hequn8128 commented on a change in pull request #9894: 
[FLINK-14342][table][python] Remove method FunctionDefinition#getLanguage.
URL: https://github.com/apache/flink/pull/9894#discussion_r334450253
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/PythonUtil.scala
 ##########
 @@ -40,6 +42,15 @@ object PythonUtil {
     node.accept(new FunctionFinder(language, recursive))
   }
 
+  /**
+    * Checks whether the specified function is python function.
+    *
+    * @param function the function to check.
+    * @return true if it is python function.
+    */
+  def isPythonFunction(function: UserDefinedFunction): Boolean =
 
 Review comment:
   Change this to
   ```
     def isPythonCall(rexCall: RexCall): Boolean = rexCall.getOperator match {
       case sfc: ScalarSqlFunction => 
sfc.getScalarFunction.isInstanceOf[PythonFunction]
       case _ => false
     }
   ```
   so that we can simply the logic in `FunctionFinder` with:
   ```
     private class FunctionFinder(findPythonFunction: Boolean, recursive: 
Boolean)
       extends RexDefaultVisitor[Boolean] {
   
       override def visitCall(call: RexCall): Boolean = {
         findPythonFunction == isPythonCall(call) ||
           (recursive && call.getOperands.exists(_.accept(this)))
       }
   
       override def visitNode(rexNode: RexNode): Boolean = false
     }
   ```
   And also can simplify the visitCall method in `ScalarFunctionSplitter` with:
   ```
     override def visitCall(call: RexCall): RexNode = {
       visit(isPythonCall(call), call)
     }
   ```

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


With regards,
Apache Git Services

Reply via email to