You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Jark Wu (Jira)" <ji...@apache.org> on 2021/10/07 15:52:00 UTC

[jira] [Comment Edited] (FLINK-24473) getString value from any datatype columns

    [ https://issues.apache.org/jira/browse/FLINK-24473?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17425647#comment-17425647 ] 

Jark Wu edited comment on FLINK-24473 at 10/7/21, 3:51 PM:
-----------------------------------------------------------

From the exception message, the field type is int type, so you can't use {{getString}}. You should use {{getInt()}} can cast to string instead. 

If you are looking for a more general way to convert any type into string, you use {{org.apache.flink.table.data.RowData#createFieldGetter}} to get a {{FieldGetter}} which can get an Object field from the RowData, and then use {{toString}} on the object. 


was (Author: jark):
From the exception message, the field type is int type, so you can't use {{getString}}. You should use {{getInt()}} can cast to string instead. 

If you are looking for a more general way to convert any type into string, you use {{org.apache.flink.table.data.RowData#createFieldGetter}} to get a {{FieldGetter}} which can get an Object from the RowData, and then use {{toString}} on the object. 

> getString value from any datatype columns
> -----------------------------------------
>
>                 Key: FLINK-24473
>                 URL: https://issues.apache.org/jira/browse/FLINK-24473
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table SQL / API
>    Affects Versions: 1.12.4
>            Reporter: Spongebob
>            Priority: Minor
>         Attachments: image-2021-10-07-21-17-20-192.png
>
>
> Hope flink would support getting string value from any other datatype column, such as from int、decimal column. At current flink would throw cast exception when we do that.
>  
> !image-2021-10-07-21-17-20-192.png!



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