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

Dian Fu closed FLINK-40300.
---------------------------
    Resolution: Fixed

Merged to master via b810155feca84317d9cbfa1c1db8335b70d3c0d1

> PyFlink Table API lit fails for some literal types
> --------------------------------------------------
>
>                 Key: FLINK-40300
>                 URL: https://issues.apache.org/jira/browse/FLINK-40300
>             Project: Flink
>          Issue Type: Bug
>          Components: API / Python
>            Reporter: Liu Liu
>            Assignee: Liu Liu
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 2.4.0
>
>
> {{pyflink.table.expressions.lit(value, data_type)}} and {{lit(value)}} both 
> pass Python values across Py4J before invoking the Java Table API. For 
> explicitly typed literals, Py4J converts Python values to general Java types 
> that may not match the declared data type’s conversion class, such as 
> {{java.lang.Integer}} instead of {{{}java.lang.Short{}}}. For inferred 
> literals, Python temporal values cannot be serialized directly, while Python 
> sequences arrive as generic Java containers that do not preserve the concrete 
> array types required by Java literal inference. Raw constructed value 
> literals may also be created but cannot be planned.
> For example:
> {{from pyflink.table import DataTypes}}
> {{from pyflink.table.expressions import lit}}
> {{lit(1, DataTypes.SMALLINT(False))}}
> This fails with:
> {{org.apache.flink.table.api.ValidationException:
> Data type 'SMALLINT NOT NULL' with conversion class 'java.lang.Short'
> does not support a value literal of class 'java.lang.Integer'.}}
> For explicitly typed literals, the issue affects at least {{{}TINYINT{}}}, 
> {{{}SMALLINT{}}}, {{BIGINT}} for 32-bit values, {{{}FLOAT{}}}, {{{}DATE{}}}, 
> {{{}TIME{}}}, {{{}TIMESTAMP{}}}, {{{}TIMESTAMP_LTZ{}}}, intervals, and 
> constructed types. Without an explicit data type, it affects Python temporal 
> values, lists, tuples, {{{}array.array{}}}, and nested arrays. Constructed 
> {{{}ARRAY{}}}, {{{}MAP{}}}, and {{ROW}} values also require recursive 
> conversion and plannable constructor expressions. The DataFrame API is 
> affected because its {{lit}} method delegates to the Table API implementation.



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

Reply via email to