[
https://issues.apache.org/jira/browse/BEAM-12180?focusedWorklogId=593344&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-593344
]
ASF GitHub Bot logged work on BEAM-12180:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 07/May/21 14:56
Start Date: 07/May/21 14:56
Worklog Time Spent: 10m
Work Description: TheNeuralBit commented on a change in pull request
#14568:
URL: https://github.com/apache/beam/pull/14568#discussion_r623327836
##########
File path: sdks/python/apache_beam/dataframe/schemas_test.py
##########
@@ -203,19 +223,32 @@ def test_batch_with_df_transform(self):
proxy=schemas.generate_proxy(Animal)))
assert_that(res, equal_to([('Falcon', 375.), ('Parrot', 25.)]))
+ def assert_typehints_equal(self, left, right):
+ left = typehints.normalize(left)
+ right = typehints.normalize(right)
+
+ if _match_is_named_tuple(left):
+ self.assertTrue(_match_is_named_tuple(right))
+ self.assertEqual(left.__annotations__, right.__annotations__)
+ else:
+ self.assertEqual(left, right)
+
@parameterized.expand(SERIES_TESTS + NOINDEX_DF_TESTS)
- def test_unbatch_no_index(self, df_or_series, rows):
+ def test_unbatch_no_index(self, df_or_series, rows, beam_type):
proxy = df_or_series[:0]
with TestPipeline() as p:
res = (
p | beam.Create([df_or_series[::2], df_or_series[1::2]])
| schemas.UnbatchPandas(proxy))
+ # Verify that the unbatched PCollection has the expected typehint
+ self.assert_typehints_equal(res.element_type, beam_type)
Review comment:
I don't think BEAM-8538 is the issue, the problem seems to be just that
`sub` and `base` are two distinct NamedTuple types. They have the same fields
in the same order, but that doesn't satisfy the `issubclass` check.
https://github.com/apache/beam/blob/fd33f16882fcedd77ec1e4ab553328bce4a277ac/sdks/python/apache_beam/typehints/typehints.py#L1179
Perhaps I should add logic for checking the types of NamedTuple fields to
`is_consistent_with`, something like:
```
if (_match_is_named_tuple(base))
# Check if any of sub's parents are NamedTuples?
self.assertEqual(sub.__annotations__, base.__annotations__)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 593344)
Time Spent: 2h 10m (was: 2h)
> UnbatchPandas (and to_pcollection) do not set type hint for unbatched
> DataFrames
> --------------------------------------------------------------------------------
>
> Key: BEAM-12180
> URL: https://issues.apache.org/jira/browse/BEAM-12180
> Project: Beam
> Issue Type: Improvement
> Components: sdk-py-core
> Affects Versions: 2.26.0, 2.27.0, 2.28.0, 2.29.0
> Reporter: Brian Hulette
> Assignee: Brian Hulette
> Priority: P2
> Fix For: 2.30.0
>
> Time Spent: 2h 10m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)