[ 
https://issues.apache.org/jira/browse/FLINK-10965?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Timo Walther closed FLINK-10965.
--------------------------------
    Resolution: Won't Fix

Legacy planner is reaching end of life.

> suggest that change $resultTypeTerm to Object at 
> org.apache.flink.table.codegen.calls.ScalarFunctionCallGen:104
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-10965
>                 URL: https://issues.apache.org/jira/browse/FLINK-10965
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Legacy Planner
>    Affects Versions: 1.5.5
>         Environment: 1.5.4
>            Reporter: shaomeng.wang
>            Priority: Major
>              Labels: stale-major
>
> at org.apache.flink.table.codegen.calls.ScalarFunctionCallGen:104
>  
>  
> {code:java}
> val functionCallCode =
>  s"""
>  |${parameters.map(_.code).mkString("\n")}
>  |$resultTypeTerm $resultTerm = $functionReference.eval(
>  | ${parameters.map(_.resultTerm).mkString(", ")});
>  |""".stripMargin{code}
>  
>  
> when wrap a scalar function from another, I use the prototype of "eval" and 
> "getResultType" as
>  
> {code:java}
> public Object eval(Object... objs) throws Exception
> public TypeInformation<?> getResultType(Class<?>[] signature) {
> {code}
>  
> but, in codegen, it is change to
>  
> {code:java}
> String reseult = eval(...){code}
>  
> when getResultType return Types.STRING
> and get error message as:
>  
>  
> {panel:title=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)
> {panel}
>  
>  
> the gen code is:
>  
>  
> {code:java}
> @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);
> }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to