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

xuyang updated FLINK-27952:
---------------------------
    Attachment: image-2022-06-21-00-19-12-151.png

> Table UDF fails when using Double.POSITIVE_INFINITY as parameters
> -----------------------------------------------------------------
>
>                 Key: FLINK-27952
>                 URL: https://issues.apache.org/jira/browse/FLINK-27952
>             Project: Flink
>          Issue Type: New Feature
>          Components: Table SQL / Planner
>            Reporter: Zhipeng Zhang
>            Priority: Major
>         Attachments: image-2022-06-21-00-19-12-151.png
>
>
>  
> The following code fails and throws NumberFormatException when casting 
> Double.POSITIVE_INFINITY to BigDecimal.
> {code:java}
> @Test
> public void testTableUdf() {
>     StreamExecutionEnvironment env = 
> StreamExecutionEnvironment.getExecutionEnvironment();
>     DataStream <Row> data = env.fromElements(Row.of(1.), Row.of(2.));
>     StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
>     Table table = tEnv.fromDataStream(data).as("f0");
>     Double[][] d = new Double[][]{new Double[]{1.0, 
> Double.POSITIVE_INFINITY}};
>     Expression[] expressions = new Expression[2];
>     expressions[0] = org.apache.flink.table.api.Expressions.call(MyUDF.class, 
> $("f0"), d);
>     expressions[1] = org.apache.flink.table.api.Expressions.call(MyUDF.class, 
> $("f0"), d);
>     table.addColumns(expressions)
>         .as("f0", "output", "output2")
>         .execute().print();
> }
> public static class MyUDF extends ScalarFunction {
>     public Integer eval(Integer num, Double[][] add) {
>         return (int)(num + add[0][0]);
>     }
> } {code}
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to