[FLINK-37616][python] Fix incorrect unpickling of Row fields #26403
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
If you call
TableEnvironment.from_elements
where one of the fields in the row contains aRow
, for example where one of the values you pass in is:where the schema for the field is:
When you call
execute().collect()
on the table, the array is returned as:Instead of each
Row
having 3 values, the collected row only has 1 value, which is now a list of the actual values in the row. The input and output rows are no longer equal (as their internal_values
collection are no longer equal, one being a list of strings and the other being a list of a list of strings). Thelen()
of the source Row is correctly returned as 3, but the collected row incorrectly reports alen()
of 1.The constructor for
Row
is such that it takes an arbitrary number of parameters as values, so that:Produces a
Row
whose internal_values
would be a list of those values:["hello", "world", 1, 2, 3, ["hello", "world"]
The
pickled_bytes_to_python_converter
builds a list of fields from the pickled bytes, but then passes this list to theRow
constructor as one, single argument - essentially constructing the Row with just one field (when it should have all the fields that were collected). This list of fields should be unpacked with*
when passing them into theRow
constructor, such that each field acts as a parameter to the constructor.Brief change log
Row
type during collection.Verifying this change
This change added tests and can be verified as follows:
(example:)
StreamTableEnvironmentTests.test_collect_for_all_data_types
test to properly construct sourceRow
s, and to check that theRow
s returned fromexecute().collect()
have the same internal structure as the sourceRow
s.Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (maybe?)Documentation