You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/09/13 11:54:00 UTC

[jira] [Updated] (FLINK-27952) Table UDF fails when using Double.POSITIVE_INFINITY as parameters

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

ASF GitHub Bot updated FLINK-27952:
-----------------------------------
    Labels: pull-request-available  (was: )

> 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
>              Labels: pull-request-available
>         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.10#820010)