Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-10965

suggest that change $resultTypeTerm to Object at org.apache.flink.table.codegen.calls.ScalarFunctionCallGen:104

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.5.5
    • None
    • 1.5.4

    Description

      at org.apache.flink.table.codegen.calls.ScalarFunctionCallGen:104

       

       

      val functionCallCode =
       s"""
       |${parameters.map(_.code).mkString("\n")}
       |$resultTypeTerm $resultTerm = $functionReference.eval(
       | ${parameters.map(_.resultTerm).mkString(", ")});
       |""".stripMargin

       

       

      when wrap a scalar function from another, I use the prototype of "eval" and "getResultType" as

       

      public Object eval(Object... objs) throws Exception
      public TypeInformation<?> getResultType(Class<?>[] signature) {
      

       

      but, in codegen, it is change to

       

      String reseult = eval(...)

       

      when getResultType return Types.STRING

      and get error message as:

       

       

      error msg

      Caused by: org.codehaus.commons.compiler.CompileException: Line 121, Column 13: Assignment conversion not possible from type "java.lang.Object" to type "double"
      at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:11672)
      at org.codehaus.janino.UnitCompiler.assignmentConversion(UnitCompiler.java:10528)
      at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:3452)
      at org.codehaus.janino.UnitCompiler.access$5200(UnitCompiler.java:212)
      at org.codehaus.janino.UnitCompiler$9.visitAssignment(UnitCompiler.java:3416)
      at org.codehaus.janino.UnitCompiler$9.visitAssignment(UnitCompiler.java:3396)
      at org.codehaus.janino.Java$Assignment.accept(Java.java:4300)
      at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:3396)
      at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2316)
      at org.codehaus.janino.UnitCompiler.access$1700(UnitCompiler.java:212)
      at org.codehaus.janino.UnitCompiler$6.visitExpressionStatement(UnitCompiler.java:1450)
      at org.codehaus.janino.UnitCompiler$6.visitExpressionStatement(UnitCompiler.java:1443)
      at org.codehaus.janino.Java$ExpressionStatement.accept(Java.java:2848)
      at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:1443)
      at org.codehaus.janino.UnitCompiler.compileStatements(UnitCompiler.java:1523)
      at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1509)
      at org.codehaus.janino.UnitCompiler.access$1600(UnitCompiler.java:212)

       

       

      the gen code is:

       

       

      @Override
       public void flatMap(Object _in1, org.apache.flink.util.Collector c) throws Exception {
       org.apache.flink.types.Row in1 = (org.apache.flink.types.Row) _in1;
       
      boolean isNull$1 = (java.lang.String) in1.getField(0) == null;
      java.lang.String result$0;
      if (isNull$1) {
       result$0 = "";
      }
      else {
       result$0 = (java.lang.String) (java.lang.String) in1.getField(0);
      }
       
       
       
      
      java.lang.String result$2 = function_com$test$Test.eval(
       isNull$1 ? null : (java.lang.String) result$0);
      
      boolean isNull$4 = result$2 == null;
      java.lang.String result$3;
      if (isNull$4) {
       result$3 = "";
      }
      else {
       result$3 = (java.lang.String) result$2;
      }
      
      if (isNull$4) {
       out.setField(0, null);
      }
      else {
       out.setField(0, result$3);
      }
      c.collect(out);
      }
      

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            shaomeng.wang shaomeng.wang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: