4

I'm trying to make a side input from a pcollection in apache beam with python.

This is my code:

from apache_beam.pvalue import AsList

locations_dim = p | beam.io.Read(beam.io.BigQuerySource(
query='SELECT a, b, c, d FROM test.testing_table')) | 
beam.Map(format_apply)

AsList(locations_dim) | WriteToText(known_args.output)

(I apply WritToText in order to debug) But it raises the following error:

self.value = tuple(value)
TypeError: 'AsList' object is not iterable

Any help?

SaadK
  • 256
  • 2
  • 10
  • 1
    What are you trying to do? Are you trying to write each element individually to the text file? Or are you trying to write the whole collection as a list into the file? In any case, the result of `AsList` can not be used as a main input for another PTransform. It can only be used as a side input – Pablo Dec 06 '17 at 07:18
  • Did you get an answer/solution for this error ? – Alex Jun 29 '20 at 18:28

1 Answers1

0

AsList is meant to be used for side inputs. In this case, you should be able to directly write

locations_dim | WriteToText(known_args.output)

robertwb
  • 4,891
  • 18
  • 21