sohailshk opened a new issue, #41306:
URL: https://github.com/apache/beam/issues/41306
### What happened?
`apache_beam.transforms.util.Reify.Window` is declared
`with_output_types(T)`, i.e. the output type equals the input type, but it
outputs `(element, timestamp, window)` tuples. `Reify.WindowInValue` and
`Reify.TimestampInValue` are declared to output `tuple[K, V]` but output `(key,
(value, timestamp, window))` and `(key, TimestampedValue(value, timestamp))`.
If the input has an inferred element type (for example the output of
`beam.Create`), the coder of the declared type fails on the output:
import apache_beam as beam
from apache_beam.transforms import util
with beam.Pipeline() as p:
p | beam.Create([1, 2]) | util.Reify.Window()
# 2.77.0: TypeError: an integer is required
# master from source: TypeError: '<' not supported between instances of
'tuple' and 'int'
p | beam.Create([('a', 1)]) | util.Reify.Window()
# AttributeError: 'tuple' object has no attribute 'encode'
p | beam.Create([('a', 1)]) | util.Reify.WindowInValue()
# 2.77.0: TypeError: an integer is required
p | beam.Create([('a', 1)]) | util.Reify.TimestampInValue()
# 2.77.0: TypeError: an integer is required
The same happens after a `Map(lambda x: x)`, which keeps the inferred type.
The existing tests pass because their inputs are
`TimestampedValue`/`WindowedValue` objects, whose element type has no specific
coder. Expected: the transforms work on typed input. I plan to declare the
reified part of the output as Any.
Version: 2.77.0, and master at 2a7c56bacb1.
### Issue Priority
Priority: 2 (default / most bugs should be filed as P2)
### Issue Components
- [x] Component: Python SDK
- [ ] Component: Java SDK
- [ ] Component: Go SDK
- [ ] Component: Typescript SDK
- [ ] Component: IO connector
- [ ] Component: Beam YAML
- [ ] Component: Beam examples
- [ ] Component: Beam playground
- [ ] Component: Beam katas
- [ ] Component: Website
- [ ] Component: Infrastructure
- [ ] Component: Spark Runner
- [ ] Component: Flink Runner
- [ ] Component: Prism Runner
- [ ] Component: Hazelcast Jet Runner
- [ ] Component: Google Cloud Dataflow Runner
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]