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']) 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):