You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Sergey Nuyanzin (Jira)" <ji...@apache.org> on 2023/03/09 22:15:00 UTC

[jira] [Resolved] (FLINK-31300) TRY_CAST fails for constructed types

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

Sergey Nuyanzin resolved FLINK-31300.
-------------------------------------
    Fix Version/s: 1.18.0
       Resolution: Fixed

> TRY_CAST fails for constructed types
> ------------------------------------
>
>                 Key: FLINK-31300
>                 URL: https://issues.apache.org/jira/browse/FLINK-31300
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / API
>    Affects Versions: 1.17.0, 1.16.1
>            Reporter: Sergey Nuyanzin
>            Assignee: Sergey Nuyanzin
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.18.0
>
>
> In case of problems with cast it is expected to return {{null}}
> however for arrays, maps it fails
> example of failing queries
> {code:sql}
> select try_cast(array['a'] as array<int>);
> select try_cast(map['a', '1'] as map<int, int>);
> {code}
>  {noformat}
> [ERROR] Could not execute SQL statement. Reason:
> java.lang.NumberFormatException: For input string: 'a'. Invalid character found.
> 	at org.apache.flink.table.data.binary.BinaryStringDataUtil.numberFormatExceptionFor(BinaryStringDataUtil.java:585)
> 	at org.apache.flink.table.data.binary.BinaryStringDataUtil.toInt(BinaryStringDataUtil.java:518)
> 	at StreamExecCalc$15.processElement(Unknown Source)
> 	at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.pushToOperator(CopyingChainingOutput.java:82)
> 	at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:57)
> 	at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:29)
> 	at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:56)
> 	at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:29)
> 	at org.apache.flink.streaming.api.operators.StreamSourceContexts$ManualWatermarkContext.processAndCollect(StreamSourceContexts.java:418)
> 	at org.apache.flink.streaming.api.operators.StreamSourceContexts$WatermarkContext.collect(StreamSourceContexts.java:513)
> 	at org.apache.flink.streaming.api.operators.StreamSourceContexts$SwitchingOnClose.collect(StreamSourceContexts.java:103)
> 	at org.apache.flink.streaming.api.functions.source.InputFormatSourceFunction.run(InputFormatSourceFunction.java:92)
> 	at org.apache.flink.streaming.api.operators.StreamSource.run(StreamSource.java:110)
> 	at org.apache.flink.streaming.api.operators.StreamSource.run(StreamSource.java:67)
> 	at org.apache.flink.streaming.runtime.tasks.SourceStreamTask$LegacySourceFunctionThread.run(SourceStreamTask.java:333)
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)