[FLINK-40236][python] Fix _infer_type inferring ARRAY<NULL> for a list with a leading None#28819
Open
nikolauspschuetz wants to merge 2 commits into
Open
Conversation
Collaborator
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.
nikolauspschuetz
force-pushed
the
fix-flink-40236-infer-array-leading-none
branch
from
July 25, 2026 04:35
e1903b7 to
10917a2
Compare
…ement _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.
nikolauspschuetz
marked this pull request as ready for review
July 25, 2026 17:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
_infer_typeinflink-python/pyflink/table/types.pyinferred a list's element type fromobj[0]instead of the first non-Noneelement it scans for. When the first element isNone, the array element type collapsed toNULL, making schema inference order-dependent:The
dictbranch just above already handles this correctly (it infers from the found non-Nonevalue).from_elements([Row(c=[None, 1])])without an explicit schema infersARRAY<NULL>, which then typically errors downstream.Brief change log
Noneelementvrather thanobj[0].Verifying this change
This change added a test and can be verified as follows:
TypesTests.test_infer_array_type_with_leading_noneasserting_infer_type([None, 1])yieldsArrayType(BigIntType).apache-flinkwheel: the array element type isNullTypebefore the fix andBigIntTypeafter (the all-Nonecase still yieldsARRAY<NULL>).The two commits demonstrate this: the first adds the test only (CI red —
test_infer_array_type_with_leading_nonefails withAssertionError: False is not true), the second applies the fix (CI green). Runs on my fork:Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.8)