简体   繁体   English

如何解决 Apache-Beam 中的 BeamDeprecationWarning

[英]How to solve BeamDeprecationWarning in Apache-Beam

First, Code for storing data in google cloud platform bigQuery tables after generating simple data.首先,生成简单数据后将数据存储在谷歌云平台bigQuery表中的代码。 Imported Apache-Beam library and used it.导入 Apache-Beam 库并使用它。 Runner used Google Cloud Platform Dataflow. Runner 使用了 Google Cloud Platform Dataflow。

Here code.这里的代码。

from apache_beam.options.pipeline_options import PipelineOptions
import apache_beam as beam

pipeline_options = PipelineOptions(
     project='project-id',
     runner='runner',
     temp_location='bucket-location'
)
def pardo_dofn_methods(test=None):
   import apache_beam as beam 
 class testFunction(beam.DoFn):
    def process(self, element):
        result = element.split(',')

        testing = {'test_column': result[0], 'test_column2': result[1], 'test_column3': result[2],
                       'test_column4': result[3]}
        return [testing]

    def finish(self):
        print('finish')

with beam.Pipeline(options=pipeline_options) as pipeline:
  results = (
      pipeline
      | 'Generating data' >> beam.Create([
          'test1,test2,test3,test4'
          'test5,test6,test7,test8'
       ])
      | beam.ParDo(testFunction())
      | beam.io.WriteToBigQuery(
            'project-id:bigQuery-dataset.table-name',
            schema='test_column:STRING, test_column2:STRING, test_column3:STRING, test_column4:STRING',
            create_disposition=beam.io.BigQueryDisposition.CREATE_IF_NEEDED,
            write_disposition=beam.io.BigQueryDisposition.WRITE_TRUNCATE
      )
  )

pardo_dofn_methods() pardo_dofn_methods()

It works well when run it.运行它时效果很好。 However, there are two warnings:但是,有两个警告:

BeamDeprecationWarning: options is deprecated since First stable release. References to <pipeline>.options will not be supported
 experiments = p.options.view_as(DebugOptions).experiments or []

BeamDeprecationWarning: BigQuerySink is deprecated since 2.11.0. Use WriteToBigQuery instead.
kms_key=self.kms_key))

I don't know why there is a warning.我不知道为什么会有警告。 Thank you.谢谢。

The deprecation warning "BigQuerySink is deprecated since 2.11.0. Use WriteToBigQuery instead."弃用警告“BigQuerySink 自 2.11.0 起已弃用。改用 WriteToBigQuery。” is no longer displayed when I tested WriteToBigQuery() using apache-beam==2.31.0 and runners DataflowRunner and DirectRunner .当我使用apache-beam==2.31.0和运行程序DataflowRunnerDirectRunner测试 WriteToBigQuery() 时不再显示。 Thus this should not be displayed when using version 2.31.0 onwards.因此,在使用 2.31.0 及更高版本时不应显示此内容。

The deprecation warning "options is deprecated since First stable release. References to.options will not be supported" is still shown as long as options is defined (see github reference ) to provide warning on users.只要定义了options (参见github 参考)以向用户提供警告,弃用警告“自第一个稳定版本以来不推荐使用选项。将不支持对.options 的引用”仍然显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM