[
https://issues.apache.org/jira/browse/FLINK-32494?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17738841#comment-17738841
]
Yunfeng Zhou commented on FLINK-32494:
--------------------------------------
Hi [~hxbks2ks], could you please take a look at this ticket?
> Cannot convert list literal to Table with PyFlink
> -------------------------------------------------
>
> Key: FLINK-32494
> URL: https://issues.apache.org/jira/browse/FLINK-32494
> Project: Flink
> Issue Type: Bug
> Components: API / Python
> Affects Versions: 1.16.1
> Reporter: Yunfeng Zhou
> Priority: Major
>
> During my attempt to convert a list or array to a PyFlink Table using the
> following program
> {code:python}
> from pyflink.datastream import StreamExecutionEnvironment
> from pyflink.java_gateway import get_gateway
> from pyflink.table import (
> expressions as native_flink_expr,
> StreamTableEnvironment,
> )
> from pyflink.table.types import DataTypes
> if __name__ == "__main__":
> env = StreamExecutionEnvironment.get_execution_environment()
> t_env = StreamTableEnvironment.create(env)
> table = t_env.from_elements([(1, ), (2, ), (3, )])
> # table = table.add_or_replace_columns(
> # native_flink_expr.lit([],
> DataTypes.ARRAY(DataTypes.INT()).not_null())
> # )
> table = table.add_or_replace_columns(
>
> native_flink_expr.lit(get_gateway().new_array(get_gateway().jvm.java.lang.Integer,
> 0))
> )
> table.execute().print()
> {code}
> The following exception would be thrown
> {code}
> ClassCastException: [Ljava.lang.Integer; cannot be cast to java.util.List
> {code}
> If I use the following code to create the literal expression along with the
> program above
> {code:python}
> table = table.add_or_replace_columns(
> native_flink_expr.lit([], DataTypes.ARRAY(DataTypes.INT()).not_null())
> )
> {code}
> The following exception would be thrown
> {code}
> Data type 'ARRAY<INT> NOT NULL' with conversion class '[Ljava.lang.Integer;'
> does not support a value literal of class 'java.util.ArrayList'.
> {code}
> As PyFlink does not provide a document explaining how to create Table with
> list literals, and my attempts described above both fail, there might be some
> bug in PyFlink with this function.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)