You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Nikolaus Schuetz (Jira)" <ji...@apache.org> on 2026/08/04 06:00:00 UTC

[jira] [Created] (FLINK-40322) PyFlink ArrayType/MultisetType.from_sql_type calls to_sql_type instead

Nikolaus Schuetz created FLINK-40322:
----------------------------------------

             Summary: PyFlink ArrayType/MultisetType.from_sql_type calls to_sql_type instead
                 Key: FLINK-40322
                 URL: https://issues.apache.org/jira/browse/FLINK-40322
             Project: Flink
          Issue Type: Bug
          Components: API / Python
            Reporter: Nikolaus Schuetz


{{}}
h2. Summary

{{PyFlink's [ArrayType|https://github.com/apache/flink/blob/release-2.3.0/flink-python/pyflink/table/types.py#L926]}} and [{{MultisetType}}|https://github.com/apache/flink/blob/release-2.3.0/flink-python/pyflink/table/types.py#L1054]  mistakenly call {{to_sql_type}} from their {{from_sql_type}} wrappers:
 * *MultisetType:* [https://github.com/apache/flink/blob/release-2.3.0/flink-python/pyflink/table/types.py#L1054]
 * *ArrayType:* [https://github.com/apache/flink/blob/release-2.3.0/flink-python/pyflink/table/types.py#L926]

This is a typo from the above wrapping of {{{}to_sql_type{}}}. To be clear, {{from_sql_type}} is meant to decode the internal/SQL representation back to Python. For an element type that needs conversion (e.g. {{{}DATE{}}}, whose internal form is an int day-count), decoding an {{{}ARRAY{}}}/{{{}MULTISET{}}} then feeds an {{int}} into {{{}DateType.to_sql_type{}}}, which does {{v.toordinal()}} and as expected it raises:

{{AttributeError: 'int' object has no attribute 'toordinal'}}

The sibling {{MapType.from_sql_type}} (same file) is correct — it calls {{from_sql_type}} on both key and value — so {{{}ArrayType{}}}/{{{}MultisetType{}}} are simply inconsistent with it.
h3. Reproduction
{code:python}
from pyflink.table.types import DataTypes

at = DataTypes.ARRAY(DataTypes.DATE())
at.from_sql_type([0, 1])
# expected: [datetime.date(1970, 1, 1), datetime.date(1970, 1, 2)]
# actual:   AttributeError: 'int' object has no attribute 'toordinal'
{code}
Same for {{{}DataTypes.MULTISET(DataTypes.DATE()){}}}.
h3. Fix

Call {{from_sql_type}} on each element, matching {{{}MapType.from_sql_type{}}}. Regression tests added for {{ARRAY<DATE>}} and {{{}MULTISET<DATE>{}}}.

 



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