maininformer opened a new issue, #29591:
URL: https://github.com/apache/beam/issues/29591

   ### What happened?
   
   Beam version is 2.52.0
   
   Please see the test below:
   ```python
   import apache_beam as beam
   import pyarrow as pa
   
   data_batches = [
       [{'name': 'emin', 'age': 35}, {'name': 'kobe', 'age': 2}],
       [{'name': 'annie', 'age': 6}, {'name': 'bryant', 'age': 33}]    
    ]
   
   
   class Yielder(beam.DoFn):
       def process(self, nothing):
           for batch in data_batches:
               yield batch
   
   class Returner(beam.DoFn):
       def process(self, nothing):
           for batch in data_batches:
               return batch
   
   
   print('Running Yielder')
   try:
       with beam.Pipeline() as p:
           (p
           | 'Noop' >> beam.Create([None])
           | 'Yield it' >> beam.ParDo(Yielder())
           | 'Write To Parquet' >> beam.io.parquetio.WriteToParquet(
                   file_path_prefix='output-yield',
                   schema=pa.schema([('name', pa.string()), ('age', 
pa.int64())]))
           )
   except Exception as e:
       print(e)
   
   print('\n\n')
   
   print('Running Returner')
   try:
       with beam.Pipeline() as p:
           (p
           | 'Noop' >> beam.Create([None])
           | 'Return it' >> beam.ParDo(Returner())
           | 'Write To Parquet' >> beam.io.parquetio.WriteToParquet(
                   file_path_prefix='output-return',
                   schema=pa.schema([('name', pa.string()), ('age', 
pa.int64())]))
           )
   except Exception as e:
       print(e)
   ```
   
   I expect both `Yielder` and `Returner` to have the same behavior, however in 
`parquetio.py:L119`, `row` is a list for `Yielder` and a `dict` for `Returner`. 
Thus, `Yielder` produces:
   
   ```shell
   TypeError: list indices must be integers or slices, not str
   list indices must be integers or slices, not str [while running 'Write To 
Parquet/ParDo(_RowDictionariesToArrowTable)']
   ```
   
   While `Returner` succeeds.
   
   Please run the test to reproduce. Many thanks.
   
   ### 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
   - [X] Component: IO connector
   - [ ] Component: Beam YAML
   - [ ] Component: Beam examples
   - [ ] Component: Beam playground
   - [ ] Component: Beam katas
   - [ ] Component: Website
   - [ ] Component: Spark Runner
   - [ ] Component: Flink Runner
   - [ ] Component: Samza Runner
   - [ ] Component: Twister2 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]

Reply via email to