You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "hehuiyuan (Jira)" <ji...@apache.org> on 2020/01/16 11:01:00 UTC
[jira] [Comment Edited] (FLINK-15610) How to achieve the udf that
the number of return column is uncertain
[ https://issues.apache.org/jira/browse/FLINK-15610?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17016808#comment-17016808 ]
hehuiyuan edited comment on FLINK-15610 at 1/16/20 11:00 AM:
-------------------------------------------------------------
[~lzljs3620320]
I have achieved by constructor, but it is't convenient.
If the udf is used more than once and output column's number is different, I need to register many times.
{code:java}
public int columnNumber;
public MultiKeyValueUdf(String columnNumber) {
this.columnNumber = Integer.valueOf(columnNumber);
}
@Override
public TypeInformation getResultType() {
TypeInformation[] typeInformations = new TypeInformation[columnNumber];
for(int i = 0 ; i < columnNumber;i++){
typeInformations[i] = Types.STRING();
}
return Types.ROW(typeInformations);
}
{code}
was (Author: hehuiyuan):
I have achieved by constructor, but it is't convenient.
If the udf is used more than once and output column's number is different, I need to register many times.
{code:java}
public int columnNumber;
public MultiKeyValueUdf(String columnNumber) {
this.columnNumber = Integer.valueOf(columnNumber);
}
@Override
public TypeInformation getResultType() {
TypeInformation[] typeInformations = new TypeInformation[columnNumber];
for(int i = 0 ; i < columnNumber;i++){
typeInformations[i] = Types.STRING();
}
return Types.ROW(typeInformations);
}
{code}
> How to achieve the udf that the number of return column is uncertain
> ---------------------------------------------------------------------
>
> Key: FLINK-15610
> URL: https://issues.apache.org/jira/browse/FLINK-15610
> Project: Flink
> Issue Type: Wish
> Components: Table SQL / API
> Reporter: hehuiyuan
> Priority: Major
>
> For example:[https://help.aliyun.com/knowledge_detail/98948.html?spm=a2c4g.11186631.2.3.21b81761QhpBte]
>
> {code:java}
> SELECT c1, c2
> FROM T1, lateral table(MULTI_KEYVALUE(str, split1, split2, key1, key2))
> as T(c1, c2)
> SELECT c1, c2, c3
> FROM T1, lateral table(MULTI_KEYVALUE(str, split1, split2, key1, key2, key3))
> as T(c1, c2, c3)
> {code}
> For Tablefunction:
> {code:java}
> public TypeInformation<Row> getResultType() {
> return Types.ROW(Types.STRING(),Types.STRING());
> }
> {code}
> The retrun type of `getResultType` is `TypeInformation<Row>`,i want to achieve the size of row is not fixed.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)