【问题标题】:DataFlow (PY 2.x SDk) ReadFromPubSub :: id_label & timestamp_attribute behaving unexpectedlyDataFlow (PY 2.x SDk) ReadFromPubSub :: id_label & timestamp_attribute 行为异常
【发布时间】:2018-10-28 22:12:22
【问题描述】:

我的 apache 光束管道(使用 Python SDK+ DirecrRunner 进行测试……)正在阅读 Pubsub 主题

发布的消息和属性如下:

message: [{"col1": "test column 1", "col2": "test column 1"}]
attributes:{
  'event_time_v1': str(time.time()),
  'record_id': 'row-1’,
}

我正在使用函数beam.io.gcp.pubsub.ReadFromPubSub。代码/文档提到了 id_labeltimestamp_attribute 参数(我相信这些是非常新的添加?!仅在 13 天前更新..)

  1. 当我使用 id_label 为每个元素分配一个唯一 ID 以进行重复数据删除时,我收到以下错误:

NotImplementedError: DirectRunner: id_label is not supported for PubSub reads```

为什么会这样?我的理解是否正确,仍然缺少某些代码实现,或者我在这里遗漏了什么?

  1. 当我使用timestamp_attribute = 'event_time_v1’ 时,为了给每个元素分配我自己的时间戳(在消息属性event_time_v1 中传递的客户端事件时间),我注意到实际分配给元素的时间戳仍然是消息发布时间李>

为什么会这样?我预计会是event_time_v1

我正在使用以下 DoFn 来打印元素的时间戳

class PrintFn(beam.DoFn):

      print(element, timestamp)
      return [element]

非常感谢您对此的任何解释

【问题讨论】:

    标签: python google-cloud-dataflow google-cloud-pubsub


    【解决方案1】:

    我今天遇到了同样的问题,实际上在 Jira 上存在一个未解决的问题,因为 id_label 和 timestamp_attribute 在直接运行器中不可用(我从阅读中假设,任何非数据流运行器)。在将 DataflowRunner 指定为运行器时,我已经成功地能够使用 id_label (还有一些其他问题,但这是通过)。

    Jira 问题如下:

    https://issues.apache.org/jira/browse/BEAM-4275?jql=text%20~%20%22python%20id_label%22

    因此,目前看来,使用直接跑步者还不可能做到这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-27
      • 2015-11-16
      • 2019-02-24
      • 2020-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多