我正在使用带有 Python SDK 的 Google Cloud Dataflow。
我想 :
- 从主 PCollection 中获取唯一日期列表
- 遍历该列表中的日期以创建过滤后的 PCollection(每个都有唯一的日期),并将每个过滤后的 PCollection 写入 BigQuery 中时间分区表中的分区。
我怎样才能得到那个清单?在以下组合转换之后,我创建了一个 ListPCollectionView 对象,但我无法迭代该对象:
class ToUniqueList(beam.CombineFn):
def create_accumulator(self):
return []
def add_input(self, accumulator, element):
if element not in accumulator:
accumulator.append(element)
return accumulator
def merge_accumulators(self, accumulators):
return list(set(accumulators))
def extract_output(self, accumulator):
return accumulator
def get_list_of_dates(pcoll):
return (pcoll
| 'get the list of dates' >> beam.CombineGlobally(ToUniqueList()))
我做错了吗?最好的方法是什么?
谢谢。