为 DataFlow 创建模板会引发错误 AttributeError:"RuntimeValueProvider"对象没有属性"tableId"



我已经用Apache Beam制作了一个管道,它与DataFlow运行器一起成功运行。我正在尝试创建一个模板,但是当对 apache_beam.io.gcp.bigquery.WriteToBigQuery 转换器使用 RuntimeValueProvider 时,会抛出以下错误:

AttributeError: 'RuntimeValueProvider' 对象没有属性 'tableId'

代码(摘录(如下所示:

class ProcessOptions(PipelineOptions):
@classmethod
def _add_argparse_args(cls, parser):
parser.add_value_provider_argument(
'--output_gcs',
dest='output_gcs',
default='gs://nlp-text-classification/results/stackoverflow_template',
type=str,
required=False,
help='Google Cloud Storage Path.')
parser.add_value_provider_argument(
'--output_bq_table',
dest='output_bq_table',
default='nlp-text-classification:stackoverflow.template_test',
type=str,
required=False,
help='BigQuery table.')
process_options = options.view_as(ProcessOptions)
with beam.Pipeline(options=options) as p:
[...]
"Write Posts to BigQuery" >> beam.io.WriteToBigQuery(table=process_options.output_bq_table,
schema=table_schema)
[...]

这是一个错误还是我做错了什么?

目前,数据流使用默认情况下不支持模板的运行器本机源。我们确实有一个支持模板的光束源。要使用它,您必须使用以下标志启用实验。

--experiment=use_beam_bq_sink

而不是"Write To BigQuery">>beam.io.Write(beam.io.BigQuerySink(..((我使用了beam.io.WriteToBigQuery(..(,也使用了--experiment=use_beam_bq_sink这对我有用,我不再收到以下错误 属性错误:"运行时价值提供程序"对象没有属性"数据集ID

相关内容

  • 没有找到相关文章

最新更新