From 10917a235650f8249c0e95da7f21205609ae6e0f Mon Sep 17 00:00:00 2001 From: Nikolaus Schuetz Date: Fri, 24 Jul 2026 21:35:09 -0700 Subject: [PATCH 1/2] [FLINK-40236][python] Add failing test for _infer_type with leading None Demonstrates the bug: _infer_type([None, 1]) currently yields ArrayType(NullType) because the element type is inferred from obj[0] rather than the first non-None element. Fix follows in the next commit. --- flink-python/pyflink/table/tests/test_types.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/flink-python/pyflink/table/tests/test_types.py b/flink-python/pyflink/table/tests/test_types.py index d3bd37c6ffd8f..6a415e781147b 100644 --- a/flink-python/pyflink/table/tests/test_types.py +++ b/flink-python/pyflink/table/tests/test_types.py @@ -209,6 +209,11 @@ def test_infer_schema_nulltype(self): # third column is varchar self.assertTrue(isinstance(schema.fields[2].data_type, VarCharType)) + def test_infer_array_type_with_leading_none(self): + data_type = _infer_type([None, 1]) + self.assertTrue(isinstance(data_type, ArrayType)) + self.assertTrue(isinstance(data_type.element_type, BigIntType)) + def test_infer_schema_not_enough_names(self): schema = _infer_schema_from_data([["a", "b"]], ["col1"]) self.assertTrue(schema.names, ['col1', '_2']) From 1dc127f20786a23986b8fc0383f3628911da2e3b Mon Sep 17 00:00:00 2001 From: Nikolaus Schuetz Date: Fri, 24 Jul 2026 22:42:24 -0700 Subject: [PATCH 2/2] [FLINK-40236][python] Infer array element type from first non-None element _infer_type inferred a list's element type from obj[0] rather than the first non-None element the loop scans for, so a leading None collapsed the array element type to NULL. Infer from the scanned element v instead, matching the dict branch above. This makes the test added in the previous commit pass. --- flink-python/pyflink/table/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flink-python/pyflink/table/types.py b/flink-python/pyflink/table/types.py index b62b55af9e1f3..0182a3c3d69e7 100644 --- a/flink-python/pyflink/table/types.py +++ b/flink-python/pyflink/table/types.py @@ -1491,7 +1491,7 @@ def _infer_type(obj): elif isinstance(obj, list): for v in obj: if v is not None: - return ArrayType(_infer_type(obj[0])) + return ArrayType(_infer_type(v)) else: return ArrayType(NullType()) elif isinstance(obj, array):