Github user sunjincheng121 commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3330#discussion_r101906986
  
    --- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala
 ---
    @@ -1463,21 +1465,23 @@ class CodeGenerator(
         */
       def addReusableFunction(function: UserDefinedFunction): String = {
         val classQualifier = function.getClass.getCanonicalName
    -    val fieldTerm = s"function_${classQualifier.replace('.', '$')}"
    +    val functionSerializedData = serialize(function)
    +    val fieldTerm =
    +      s"""
    +         |function_${classQualifier.replace('.', 
'$')}_${DigestUtils.md5Hex(functionSerializedData)}
    --- End diff --
    
    Thanks @fhueske  
          Regarding the name collisions ,  the current implementation is to 
meet UDTF and UDF.
    But from `tableAPI` to `SqlFunction` the creation process has some work to 
do because the current UDF parameters do not take effect.I just make a simple 
test, did not carefully check the reasons (I would like to consider in the 
FLINK-5795). Feel free to let me know If you also want merge FLINK-5794 into 
this PR。:)
    
    Thanks, @wuchong 
    1. md5Hex used for carry the construction parameters of the situation, 
without md5Hex will produce object coverage, can not produce the correct 
results.
    2. `CodeGenUtils.newName` not work well, because this method use 
`AtomicInteger.getAndIncrement` generate name number, when we use multiple UDFs 
of the same state, it will lead to the creation of multiple UDF objects, and in 
fact a shared object is sufficient. e.g.
    `
        tEnv.registerFunction("func0", new Func13)
        tEnv.registerFunction("func1", new Func13)
        tEnv.registerFunction("func2", new Func13)
    `
    `reusableMemberStatements ` will contain three different elements, can not 
do the de-duplicates. and in fact a shared object is sufficient
    
    What do you think @fhueske @wuchong ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to